Simulating the BACK button

  Michendi 23:57 17 Nov 04
Locked

The browser BACK button can be simulated in a document in everyone of the latest browsers - except IE6 - with the behaviour script onclick="window.back()" or the JavaScript a href="javascript:history.back()">. Assume a button "Close Window". If either of the above scripts are associated with this button then when a visitor clicks the button they will go back to the page they came from.... except in IE6. In IE6 the behaviour script generates an "Error on page" and the JavaScript does nothing. Does any web developer know the correct syntax to get either of these scripts to work in IE6?

  Gaz 25 01:28 18 Nov 04

"To Gaz 25. I agree that should work, but once again it doesn't in IE6. I have removed the "onclick=window.back()" script and replaced it with your script. Works fine in all the other browsers.... but $£*&^" not in IE6. Oh Bill we just love you :-( "


That's very odd, it works fine here on my website. Have you Active Scripting disabled in IE?

Otherwise, let us have a link to your website and test the code for you. This will help diagnose if the problem is with the webpage or IE on your computer.

  Taran 01:35 18 Nov 04

Back and forward history buttons, for pages visited (sorry to state the obvious)

<form>
<input type="button" value="back" onClick="opener.history.go(-1)">
<input type="button" value="forward" onClick="opener.history.go(1)">
</form>


Back button on its own:

<FORM><INPUT TYPE="BUTTON" VALUE="Go Back"
ONCLICK="history.go(-1)"></FORM>

Using an image of your own choosing as the button:

<A

HREF=

"javascript:history.go(-1)">


<IMG SRC="images/back.gif"
BORDER="0">

</A>

This assumes that your Back button image is called back.gif and is located in the images folder in your web root folder.

A standard text hyperlink back link:

<

A HREF=

"javascript:history.go(-1)">

[Go Back]</A>

Note that I've included some hard returns in the code snippets to prevent the forum from turning the links from turning into one of the blue 'click here' links.

Dynamic pages sometimes need a few extra tweaks to get a reasonably effective JavaScript 'back' button but using a cookie or (even better) a user session with cookies can allow you to offer a working solution. However, I'm not getting into that topic unless you request it and unless you specify the language you want to work with, since user sessions and cookies are no small subject for discussion.

Hope the above points you in the right direction.

T

  Michendi 18:15 20 Nov 04

Reply to TARAN...
Thanks for the info. I eventually settled on the "onclick=history.go(-1)" solution which works in all browsers tested. I had not used this specific syntax before so I have learnt something :-) Thanks.

This thread is now locked and can not be replied to.

How to get Windows 10 for free | How to install Windows 10: There is still a way to avoid paying…

1995-2015: How technology has changed the world in 20 years

Alex Chinneck’s giant ice cube Christmas tree at Kings Cross

Apple rumours & predictions 2017: The iPhone 8, new iPads, and everything else you should expect fr7…