Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    On Error Reload - Help

    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?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    <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;
    }

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 250 Times in 246 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •