vna*_*y92 11 javascript jquery html5
这是我的问题:我需要显示一段时间的消息,然后重新加载页面.有人告诉我如何在一定延迟后重新加载页面?
Sci*_*ter 36
你甚至不需要jQuery或HTML5:
setTimeout(location.reload.bind(location), 60000);
Run Code Online (Sandbox Code Playgroud)
这将等待1分钟(60,000毫秒),然后调用该location.reload
函数,这是一个刷新页面的内置函数.
Ami*_*ari 16
setTimeout(function(){
window.location.reload(); // you can pass true to reload function to ignore the client cache and reload from the server
},delayTime); //delayTime should be written in milliseconds e.g. 1000 which equals 1 second
Run Code Online (Sandbox Code Playgroud)
小智 5
您可以在没有 js 的情况下尝试此操作,它会循环:
<meta http-equiv="refresh" content="5"/> <!-- 5 sec interval-->
<h1>Page refersh in every 5 seconds...</h1>
Run Code Online (Sandbox Code Playgroud)
您甚至可以导航到不同的页面,访问谷歌主页
<meta http-equiv="refresh" content="5;http://www.google.com"/> <!-- 5 sec delay-->
<h1>Redirecting in 5 seconds...</h1>
Run Code Online (Sandbox Code Playgroud)