...

View Full Version : On Error Reload - Help



Se7eN
06-02-2004, 02:31 AM
I'd like to add to this script:

<SCRIPT language="JavaScript">
function reload()
{
window.location.replace('site.html');
return true;
}

function stop()
{
window.location.replace=null;
}

window.onerror = reload;
setTimeout("stop()", 3000);
</script>


a condition that when the page is reloaded 3 times i put an alert and disable reload()
Any sugestions?

Philip M
06-02-2004, 07:45 AM
<SCRIPT language="JavaScript">
function reload()
{
var counter = 0;
if (counter < 3) {
window.location.replace('site.html');
counter ++;
return true;
}
alert ("You are not allowed to reload more than three times!);
return false;
}

glenngv
06-02-2004, 07:58 AM
When the page reloads, all the variables do not persist and will be re-initialized. Save the counter in a persistent window property like window.name. But the question here is, why do you want to disable page reload? It is the user's right to reload the page as often as he wants to. If you tell us the real problem, maybe we can offer a real solution.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum