***222
The best web hosting EVER! Cheap, and packed with features! Take your blog to the next level!
Powered by MaxBlogPress 

TysBlog.com TysBlog.com


Spring Clearance at VistaPrint! Save up to 90%!

How to create “back” and “forward” buttons in posts and pages

April 23rd, 2008 · 5 Comments · All, design, how to, technical

Another useful, but simple tech tip

If you’re a regular reader you’ve seen me use forward and back buttons on occasion. I usually use them when I post something that requires an Iframe (an inline frame). You can see an example of this on my MyBlogLog exchange post here, and on my blogcatalog exchange post here. You’ll notice no forward buttons since clicking the link you want will take you forward, the back button is key but it can’t hurt to know how to do both.

The standard “form” method:

Here’s the code for the back button (looks like this:
)

<input TYPE=“button” VALUE=“Back” onClick=“history.go(-1);return true;”/> </form>

Here the code for the forward button (looks like this:
)

<input TYPE=“button” VALUE=“Back” onClick=“history.go(1);return true;”/> </form>

You can change the text in the buttons by simply changing the VALUE field (i.e. “Return”, “I wanna go back!”, whatever you want).

The Java script method:

Looks the same as the form method. I actually prefer the form version above as it’s less code to enter, but thought I’d share both ways of doing it.

First place the code below anywhere in your body.

<SCRIPT LANGUAGE="JavaScript">
<!-- Hide this from older browsers

function goForward() {
window.history.forward();
}

function goBack() {
window.history.back();
}

// end hide –>
</SCRIPT>

Next, place the code below where you want the button(s) to go. If you don’t want both buttons simple don’t include the blue line of code for the back button, red code for forward (same with the above code).

<FORM TARGET=”_self”>
<INPUT TYPE=”submit” VALUE=”Back” onClick=”goBack()”>
<INPUT TYPE=”submit” VALUE=”Forward” onClick=”goForward()”>
</FORM>

Again, you can change the button text by changing the VALUE field.

Note: copy the code into notepad first, then copy to your post/page - this goes for any code you copy and paste (keeps hidden attributes from being copied).

That’s all there is to it! Comment below if you have any questions.

Like this blog? Sweet! Wanna help a guy out & buy me a cup of coffee?

Please click your favorite bookmarking service below.
Save and share this page, and in turn help me
so I can continue to help you!:
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • del.icio.us
  • Furl
  • Technorati
  • Sphinn
  • TwitThis
  • Google
  • Reddit
  • Netscape
  • YahooMyWeb
  • Mixx
  • StumbleUpon


If you liked this post,do me a favor and Stumble it! Thanks!
Subscribe

Tags: ···

5 responses so far ↓

  • 1 Tina Russell // Apr 23, 2008 at 1:00 pm

    MyAvatars 0.2

    I finally decided to write a comment on your blog. I just wanted to say good job. I really enjoy reading your posts.

    Tina Russell

    [Reply]

  • 2 Sunduvan // Apr 24, 2008 at 7:59 am

    MyAvatars 0.2

    Hi, check out my free review for this blog in my blog at http://freeblogreview.blogspot.com see you there.

    [Reply]

    Ty Hurd reply on April 24, 2008:

    MyAvatars 0.2

    LOL - that has to be about the oddest review I’ve ever received… Thanks for the mention though!

    [Reply]

  • 3 Louis Liem // Apr 24, 2008 at 9:07 am

    MyAvatars 0.2

    How do they appear on feeds?

    [Reply]

    Ty Hurd reply on April 24, 2008:

    MyAvatars 0.2

    They look like this: [Back]

    You can’t go back and forth in an email. If your post has frames and/or buttons you could make a note in the post that your readers will have to visit your blog for full functionality…

    [Reply]

Leave a Comment

:) :( :d :"> :(( \:d/ :x 8-| /:) :o :-? :-" :-w ;) [-( :)>- more »