Automatically reload page with options

I try to autoload my page every 20 seconds. I use JavaScript for this, not for <meta>.

I have <body onload = "SetTimer ()"> and here is my JavaScript function

function SetTimer(){ setTimeout('window.location.replace(window.location.pathname)', 20000) } 

Now my problem is that I also pass the parameter in the query line when the first page loads. But when the page is redefined again ( window.location.pathname does not include the parameter), so I cannot assign labels to the page that are based on the parameters passed.

+2
source share
3 answers
  setTimeout('window.location.replace(window.location.href)', 2000); 

did the trick

+1
source

A simple page reload also does the trick

 function SetTimer(){ setTimeout('window.location.reload(true)', 20000) } 
+2
source

window.location will include the GET parameters that were passed.

 function SetTimer(){ setTimeout('window.location.replace(window.location)', 20000) } 

If you submit parameters via POST, the best way is probably to create a form with hidden inputs for each parameter. Submit a form every twenty seconds.

+1
source

Source: https://habr.com/ru/post/1306556/


All Articles