Forum Moderators: open

Message Too Old, No Replies

HTML 'Back' Link Won't Work in Firefox.

Back link works in Internet Explorer 6, but not in Firefox.

         

Durnovaria

12:33 am on Dec 18, 2008 (gmt 0)

10+ Year Member



Hello

Just a quick question here.

Like a fool I presumed my website that works in Internet Explorer would also work in Firefox (3.0.5 to be precise). I have been testing it in Firefox and everything works except my 'Back' links.

When I click my 'Back to Gallery' links, in Firefox it just reloads the page I am on. It works fine in IE6. Here is my code:

<a href="#" onClick="history.go(-1);return true;" class="mtn">Back
to Gallery</a>

Is there anything wrong with what I am doing there? It's just standard code as far as I am aware.

Thanks

Mike

:-)

lavazza

12:49 am on Dec 18, 2008 (gmt 0)

10+ Year Member



For once, I'm tempted to say that I'm glad there ain't no standard code for this... not across browsers, anyhoo

'Glad' cos it might give you time to reconsider you approach and NOT try to control the behaviour of your visitors' browsers

Mastery, Mystery and Misery - Jakob Nielsen [webmasterworld.com]

ETA
I found that thread by searching for the phrase

"break the back button" neilsen

[edited by: eelixduppy at 8:19 pm (utc) on Dec. 18, 2008]
[edit reason] fixed link [/edit]

jdMorgan

1:06 am on Dec 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A relatively easy way to get oriented in the battle for browser control is this: Any button or function supported by the browser's chrome --the stuff in the border around the browser's window in which your page displays-- is the property of the user, under the user's sole control, and not to be interfered-with by a Web site.

In recent years, we've seen both users and browser makers 'push back' because of abuses such as sites disabling the Back button, throwing pop-ups on window open, page load, and mouse events, replacing the browser status line, etc. Firefox is a little out in front on this, and now prohibits many JavaScript 'tricks' that used to work.

By "tricks," I mean functions and features that were somewhat useful if used for good, but very, very bad if used with malicious intent.

So, the un-requested pop-up is now dead, and site navigation is to be done with either on-page links or the browser's navigation buttons, as it was before JavaScript was supported by browsers. If you cannot get the effect you need by document.write modifying the links on each image page, then there is likely a server-side solution to your problem.

Jim

Durnovaria

1:18 am on Dec 18, 2008 (gmt 0)

10+ Year Member




Thanks for your reply Lavazza.

Far from trying to control the behaviour of my visitors' browsers I simply included that navigation option as a further choice. I thought it must be popular amongst users as it certainly appears frequently throughout the internet.

I always use my browser's Back button when I am browsing, so if these 'back' links are troublesome as well as unpopular I'll remove them.

Thanks again

Mike

:-)

Durnovaria

1:19 am on Dec 18, 2008 (gmt 0)

10+ Year Member




Thanks also for your reply, Jim.

I think I need to do a little more reading on this subject!

Mike

:-)

chizydyk

3:14 am on Dec 20, 2008 (gmt 0)

10+ Year Member



what bout just plain ol "back to home page" or "back to previous?" I dont think this "these are negatively controlling. What are your thoughts on these?

lavazza

7:14 pm on Mar 26, 2009 (gmt 0)

10+ Year Member



what bout just plain ol "back to home page"
I think that the term 'back' is inappropriate here; many (if not most) visitors 'come in through a side door' (ie if they have never (yet) been to the 'home page', its nonsensical to invite them to go 'back' there)

or "back to previous?"
All (?) relevant UAs (e.g browsers, not printers) have a back button already... why reinvent and then (for printers etc) remove the wheel?

rocknbil

9:44 pm on Mar 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<a href="#" onClick="history.go(-1);return true;" class="mtn">Back to Gallery</a>

This isn't a button breaker, but it does present some accessibility issues if JS is disabled. JD's on a good idea there, it's probably best to use document.write() to write this link to the browser so if JS is disabled it won't even be on the page.

But as to why it's not working, what you might not know is what you are doing here is Javascript, and you have to understand what return does.

In any Javascript function, the return value tells the browser whether or not to perform the natural action. For a form, it's submit; for an anchor, it's navigate to the href. Let me guess - when this link is say, in the middle of the page, it also scrolls back to the top, correct?

This is because you are returning true, which tells the browser to allow the link to navigate to the url in the href. Try

<a href="#" onClick="history.go(-1);return false;" class="mtn">Back to Gallery</a>

Further info: # is an identifier for an ID'd item on the page, and since it's a blank value, the default behavior is to scroll to the top. If you had

<a href="#bottom" onClick="history.go(-1);return true;" class="mtn">Back to Gallery</a>

and at the bottom of your page,

<p id="bottom">Bottom</p>

It would find that element and navigate to it.

P.S., you had me wondering so I just tested this in FF. Of course, you need a page to go BACK to, so navigate to something first before opening the page with this link.

tedster

9:56 pm on Mar 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also note that using "back to gallery" for clickable text may be a problem. You're assuming that everyone has arrived at this page from a Gallery page. The history will take the visitor to wherever they were before, no matter where that is.