0

I want to give a small alert that page is reloaded after refreshing the entire page.

This is what I have done to refresh the page:

 window.onunload = function () {
      alert("Page is refreshed");
}

And Onbody load I can give alert as

window.onload = function () {
    alert("Page is Loaded"); //<--This I dont want as only 
                             //when the page is loaded it gives me an alert.
 }

But I want to know that page is reloaded completely after refresh is done.

If page is refreshed by pressing F5 or clicking refrsh button or clicking on browsers back button I am giving alert as shown above but I would like to know how to give an alert after page is completely refreshed.(ie after refreshing the page is again reloaded after completely reloaded I need to give another alert)

1
  • @Zerkms-I have updated my question
    – coder
    Jan 29, 2012 at 21:27

3 Answers 3

1

try something like this...

window.onunload = function () {
    localStorage['refreshing'] = true;
}

window.onload = function () {
    if(localStorage['refreshing'] === true) {
        alert('win');
        localStorage['refreshing'] = false;
    }
}
2
  • i forgot, it'll need a ttl of 20 seconds at least Jan 30, 2012 at 7:44
  • +1 for being practical. Although i agree with @gdoron this feature does not sit well with the nature of web apps.
    – cctan
    Jan 30, 2012 at 7:45
0

I would like to know how to give an alert after page is completely refreshed.

Web applications are stateless so it can not be done. you can never know if this is the first visit or second visit (unless you store your's visitors visits with some sort of Data Base.)

0

DotNetter it is still unclear that what u really want But I guess document.ready method helps you out in some way

$(document).ready(function(){
   alert(page ready)
});

Hopeit helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.