Forum Moderators: open

Message Too Old, No Replies

checking history object to create back / foward buttons

only want to show button if there is history

         

lethal0r

10:18 am on Apr 5, 2007 (gmt 0)

10+ Year Member



i am using javascript to create two links on a page, one called 'back' and one called 'forward', each navigating to the relevant page in the browsers history. I only want the link to show if there is history - if there is nowhere to go forward, i dont want the forward link to show.

when i check to see if there is history like the example below, it doesnt check it, it actually navigates straight to the page im checking instead.

if(window.history.forward(1)!= null) {
<a href="javascript:history.go(1)">forward</a>;
}

this is tested in firefox 2. is it possible to do what i want?

Dabrowski

10:39 am on Apr 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's because history.forward is the function that actually goes there.

You used to be able to access the history object to check but access was removed a long time ago as it's a security risk for a website to be able to check what other sites you access.

While any of us have legitimate reasons for checking history, you can see the obvious security implications it has.