0

Is it possible to reload a page for a specific amount of times, let us say I want to reload a page for 10 times once the dom is loaded?

mquemazz
  • 763
  • 3
  • 12
  • 18
  • 7
    .. Why?​​​​​​​​​​ – Madara's Ghost Mar 10 '15 at 12:59
  • This has already been answered.. http://stackoverflow.com/questions/2787679/how-to-reload-page-every-5-second – Dayan Mar 10 '15 at 13:00
  • Dayan you understood the question in a wrong way, I don't wanna reload the page every specified amount of time I want to reload it for number of times – mquemazz Mar 10 '15 at 13:04
  • 1
    Adding to what @Dayan link says (the JavaScript way, not using the header), if you want to reload the page just a certain amount of times, save a value in a cookie or in the localStorage and retrieve/update it before reloading the page with JavaScript – Alvaro Montoro Mar 10 '15 at 13:05

1 Answers1

0
window.onload=function(){
if(!window.localStorage.getItem("count"))
    window.localStorage.setItem("count",0);
else
   {
    var count= window.localStorage.getItem("count");
       if(count<10)                                              
       {
          window.localStorage.setItem("count",count+1);location.reload();
       }
   }
  };
balajisoundar
  • 581
  • 2
  • 11