Click to See Complete Forum and Search --> : window.back


mg8
09-26-2003, 03:59 PM
I want it to load, then if you can go back, go back. If you can't, close the window. Doesn't make much sense but stick with me:

<html>
<body>
<script language="javascript" type="text/javascript">
function zargon()
{
if (window.back()) {
window.back();
}
else {
window.close();
}
}
</script>
<body onLoad="zargon()">
</body>
</html>

That is what I have. I get an error with the window.back() thing and I'm not sure why? Is the problem with mixing Javascript and HTML?

pyro
09-26-2003, 04:29 PM
You can not tell if the back button was clicked with JavaScript. The best you can do is know when the page is being unloaded (via onunload). This will, however, trigger whenever the page's locatoin changes/is refreshed.