How to write a javascript for reloading a page in the same tab after every t seconds?
I am javascript newbie. I need to collect the packet traces for a webpage by reloading it in the sam开发者_如何学Pythone tab every 30 seconds. How can I do this using javascript?
You can either use a HTML only solution:
<meta http-equiv="refresh" content="30; URL=http://www.yourdomain.com/yoursite.html">
Or use Javascript:
setTimeout(function(){
window.location.reload(1);
}, 30000);
Both ways refresh the current page every 30 seconds. Right from MDC:
Reload the document from the current URL. forceget is a boolean, which, when it is true, causes the page to always be reloaded from the server. If it is false or not specified, the browser may reload the page from its cache.
精彩评论