我将一个布局转换为html;一旦我在code/html/css中做了更改,每次我都要按F5。有没有简单的javascript/jQuery解决方案?也就是说,在我添加脚本后,每5秒(或其他特定时间)重新加载整个页面。


当前回答

 <meta http-equiv="refresh" content="5; URL=http://www.yourdomain.com/yoursite.html">

如果必须在脚本中使用setTimeout:

setTimeout(function(){
   window.location.reload(1);
}, 5000);

其他回答

setTimeout(function () { location.reload(1); }, 5000);

但是随着开发工具的发展,使用标签重新加载扩展可能会更好。

要重新加载同一页面,您不需要第二个参数。你可以用:

 <meta http-equiv="refresh" content="30" />

这将触发每30秒重新加载一次。

 <meta http-equiv="refresh" content="5; URL=http://www.yourdomain.com/yoursite.html">

如果必须在脚本中使用setTimeout:

setTimeout(function(){
   window.location.reload(1);
}, 5000);

对于自动重载和清除缓存后3秒,你可以很容易地使用javascript setInterval函数。下面是简单的代码

$(文档)时函数(){ setInterval(函数(){ cache_clear () }, 3000); }); 函数cache_clear() { window.location.reload(真正的); / / window.location.reload ();如果您不删除缓存,请使用此选项 } < script src = " https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js " > < /脚本> <p>自动重载页面并清除缓存</p> .

你也可以用meta来做这个

<meta http-equiv="Refresh" content="5">

函数reload() { document.location.reload (); } setTimeout(重载,5000);