By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,729 Members | 1,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,729 IT Pros & Developers. It's quick & easy.

need back script for safari

P: n/a
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?
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In article
<no*******************@c211-28-190-157.mckinn1.vic.optusnet.com.au>,
woodsie <no**@none.com> wrote:
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)
Jul 23 '05 #2

P: n/a
woodsie wrote:
*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? *


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

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

This works in Safari
-
dBrippe

Jul 23 '05 #3

P: n/a
dBrippel <dB*************@mail.forum4designers.com> writes:
woodsie wrote:
<a href="#" onClick="history.go(-1)">go back</a>
.... 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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.