Click to See Complete Forum and Search --> : Checking for history +1....
mawood
02-13-2003, 02:10 PM
How do I check to see if history +1 is true? I want to perform a function only if used the back button to return. Something along the lines of:
if (window.history.forward(1)) {
.......
} else {
...
}
help?
Nevermore
02-13-2003, 02:14 PM
Impossible - sorry. Once the back button is pushed, no more code can execute on your page. Your only way top do this is to make sure they are going back to another of your pages. That page can be made to perform an action only if they came from your page using document.referrer
mawood
02-13-2003, 02:19 PM
So, if I use document.referrer, and they use the back button, is the referrer the page they were on when they hit the back button? If so, that would be the same same thing for what I am doing.
Nevermore
02-13-2003, 03:14 PM
Sorry, I got that wrong. Check out a previous post (called 'no histroy(-1) allowed', I think - with the spelling error) for a more in depth discussion, but the easiest way to do this is:
Create a 'splash screen' - a page which automatically redirects the user to your other page. This will send them to your original page whenever they hit back. If you want you could use cookies to only send them to your page once, but i find that sort of thing unnecessary - they can still use the drop down by back. Or, if you actually want to grey out the back button entirely:
Make the splash screen open your page in a new window! To do this use something like:
window.open("URL");
PM me with any questions.