help with javascript history object...

They have: 447 posts

Joined: Oct 1999

im trying to create a link that will send the user back a page. Ive tried:
<A CLASS=listing HREF='javascript:void(0);' ONCLICK='window.history.back()'>[Go Back]</A>

<A CLASS=listing HREF='javascript:void(0);' ONCLICK='self.history.back()'>[Go Back]</A>

<A CLASS=listing HREF='javascript:void(0);' ONCLICK='history.back()'>[Go Back]</A>

<A CLASS=listing HREF='javascript:void(0);' ONCLICK='document.history.back()'>[Go Back]</A>

and many other variations but i cant get it to work. what am i doing wrong?

They have: 122 posts

Joined: Jun 1999

I would kind of like to know all the history commands. Anyway, I have always seen those with a -1 in the parenthesis, but they probably work without it. The last one with document.history.back() doesn't work. Anyway, here is what I tried and they all worked:

<A HREF="javascript:window.history.back(-1)">[Go Back]</A>
<A HREF="javascript:self.history.back(-1)">[Go Back]</A>
<A HREF="javascript:history.back(-1)">[Go Back]</A>

They have: 447 posts

Joined: Oct 1999

works great, thanks!

AndyB's picture

They have: 344 posts

Joined: Aug 1999

javascript:history.go(-1) takes you back ... and history.go(1) takes you forward (assuming you were there before, if you know what I mean)

and history.go(-x) takes you back x pages

[This message has been edited by AndyB (edited 21 June 2000).]

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi,

history.go(0) refreshes the page. This is a necessary code for anyone who builds dynamic selection lists (or other fields that require resizing) and doesn't want NN to mess up the re-display. Generally, I fill the selection list and then:

if (Netscape) // or somesuch
history.go(0);

You can also use history.go(x). The history.back() & forward() methods seems to be too problematic and undependable.

Vinny

------------------
my site:GrassBlade: cut&paste javascript
moderator at:The Javascript Place
Javascript City

Where the world once stood
the blades of grass cut me still

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.