need back script for safari

W

woodsie

i'm looking for a back script that will work in Safari (on mac).
the one below works fine in IE and netscape but not safari.

<a href="#" onClick="history.go(-1)">go back</a>

any help plz?
 
M

max power

woodsie said:
i'm looking for a back script that will work in Safari (on mac).
the one below works fine in IE and netscape but not safari.

<a href="#" onClick="history.go(-1)">go back</a>

any help plz?

use history.back() instead of history.go(-1)
 
L

Lasse Reichstein Nielsen

dBrippel said:
....
You can use history.go(-1), but don't use the "#" and the "onClick"
command:

<a href="javascript:history.go(-1)">go back</a>

I disagree. You only need to use "javascript:" when you are creating
bookmarklets. In all other cases, you should use onclick instead.
<URL: http://jibbering.com/faq/#FAQ4_24 >

I don't know what the problem with Safari is, but I won't believe
that it's onclick handlers not working. Try:
<a href="..." onClick="history.go(-1);return false;">go back</a>

Now, the big question is what to write instead of "...".

I agree that "#" and "" are not good solutions (both link back to
the same page, which is not a good behavior for a link that says
"go back").

Since the href is only used if Javascript fails, you cannot use
Javascript to fill it out.
Either 1) use server side scripting to make it link to the previous
page based on the referrer header, if present, 2) make it link to
a plausible previosu page, or 3) make it link to a page that tells
the user that he needs Javascript.

A different solution is to only include the link if Javascript is
enabled, either by creating it using Javascript, or by hiding it
using CSS and unhide it using Javascript.


Anyway, I think it is a bad idea to reimplement basic browser
interface functions. There is already a back button, and it works
100% of the time.

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top