[thelist] best way to create "back" button

.jeff jeff at members.evolt.org
Fri Jul 12 03:25:01 CDT 2002


mark & john-paul,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Mark Gallagher
>
> <a href="#" onClick="history.go(-1)">Back</a>
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

and if you wanna be xhtml valid, you'll write that event handler in all
lowercase:

onclick="history.go(-1)"

at all costs, avoid the ultra-annoying use of the # as a filler for the href
attribute.

Links & JavaScript Living Together in Harmony
http://evolt.org/article/thelist/17/20938/

there are other much larger issues with using history.go(-1) though.
consider what might happen if someone visits the page from a link on another
site?  in that instance is the "back button" you're trying implement really
intended to send the user back out of your site?  probably not.  in most
cases when adding "back buttons" on pages it's to take the user to a less
specific page than the one they're currently viewing -- news article to
listing of articles, image to gallery of images, product detail to product
listings, etc.  *if* the user came from the more general page the word
"back" makes sense.  however, all too often that's not the case in which the
word "back" only makes sense if you're actually duplicating the
functionality of the back button the browser provides with the caveats
previously mentioned.

my advice?  don't ever use the word "back" to as a link.  don't use
javascript or some form of unreliable server-side mumbo jumbo involving the
referer to duplicate functionality that already exists in the browser.
you'll only confuse the user.  instead, either leave out the link entirely
if you want to offer "back" functionality or use different wording if you
want to go from a detail page of sorts to a more general page -- "events" if
you're taking the user from an event to the events listing page, "frequently
asked questions" if you're taking the user from an faq page to an faq
listings page, etc.

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/





More information about the thelist mailing list