Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to detect if web page is refreshed using Javascript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 352
    Comment on it

    Hello Reader's! if you need to detect whether the webpage is being refreshed by using Javascript you can do this like the example below:-

    function CheckRefresh() {
      if(document.cookie.indexOf('mycookie')==-1) {
        // cookie doesn't exist, create it now
        document.cookie = 'mycookie=1';
      }
      else {
        // not first visit, so alert
        alert('Page is just refreshed!');
      }
    }
    

    and in your body tag:

    <body onload="CheckRefresh()">
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: