Click to See Complete Forum and Search --> : back button
jean-baptiste
02-26-2003, 04:11 PM
Hi,
How to control the navigator's back button ?
It is possible to redirect the page where i want or stop the session when the user press on back button ?
Thank you,
Phil Karras
02-26-2003, 05:15 PM
At one time we could do just about anything to the array of URLs in the previous var, unfortunately I'm not sure we still can. Things were changed when security issues came to light and so all browsers & JS changed to protect previous URLs from being printed, etc.
Now, as to controlling the back arrow button uses something like the JS method:
history.go(-1);
You can make your own buttons that can go back or forward any number of places, as in:
history.go(-3); - back three URLs, if they exist.
Now, as to loading the array of past URLs? Again, I don't think we have that control any longer.
Anyone else know differently?
There's the var: document.referrer
and then there was the array (I believe): history.previous
jean-baptiste
02-26-2003, 07:37 PM
Thanks for you response.
If I include/understand well, it there not JavaScript event which makes it possible to control the back button of navigator. However, in certain banking sites when you click on the back button during a session the site you log off automatically. Any idea?
dabush
02-26-2003, 09:43 PM
javascript can not CONTROL the back button, it can just USE it.
Phil Karras
02-27-2003, 09:50 AM
OK, while we can not control the action of the browser back arrow button (BAB) we can control what happens when you leave our page.
onBlur fires whenever focus moves to another page, or the BAB is used, also I believe there's onUnload() which fires when the user tries to leave your page:
<body onUnload='OutOfHere();'>
Where OutOfHere() is a function called when this page is exited. (The BAB is pressed.)
jean-baptiste
02-27-2003, 03:08 PM
Ok this code seems work :
vbscript :
<SCRIPT LANGUAGE="VBScript" >
<!--
sub OutofHere()
...
end sub
-->
</SCRIPT>
<BODY Language="VBS" onUnload = "OutofHere">
javascript :
<SCRIPT LANGUAGE="JavaScript" FOR="window" EVENT="onunload">
...
</SCRIPT>
Thank you
Phil Karras
02-27-2003, 03:21 PM
I must admit that I have never seen "sub" used in JavaScript. The correct form (as supported by the w3c standard) is:
<SCRIPT LANGUAGE="VBScript" >
<!--
function OutofHere() {
// code goes here
}
-->
</SCRIPT>
dabush
02-27-2003, 04:54 PM
hence the line
<SCRIPT LANGUAGE="VBScript">
Sub is a part of VBScript.
Phil, you are correct, it is NOT JavaScript, and therefore jean, you are posting in the wrong forum (although you can continue with this thread if you want to learn how to do it in JavaScript).
Phil Karras
02-28-2003, 09:00 AM
Right, thanks, I hadn't even looked at the script tag.