在下面的代码/ JS中。我只想在单击处理程序触发后(或单击按钮后)‘刷新’页面。约2或3秒钟后,单击已启动。所以基本上按钮点击,2-3秒已经过去,然后页面刷新。我想要用纯的JS,而不是jQuery或使用<meta>。
以下是我的JS:
$('.download-pdf').click(function() {
// I would like to add here
notChecked = $("input[type=checkbox]:not(:checked)").parent();
notChecked.hide();
yesChecked = $("input[type=checkbox]:checked").parent();
$.each(yesChecked, function( index, el ) {
$(el).show().html(texts[$(el).attr('id')]);
});发布于 2015-12-08 16:26:00
使用setTimeout()
setTimeout(function(){
location.reload();
},3000);发布于 2015-12-08 16:30:08
您可以使用简单的settimeout()函数在一定时间后延迟一个函数。
您可以使用location.reload();刷新页面,更新数据后由我自己使用。
延迟毫秒表示页面重新加载之前所需的秒数。它以毫秒为单位表示,所以1秒/1000。在这种情况下,您可能希望投入3000英镑。
下面是一个示例:
setTimeout(function(){
location.reload();
}, thedelayinmiliseconds);发布于 2015-12-08 16:28:46
若要在2秒后重新加载页面,请使用以下命令
setTimeout(function(){ window.location.reload()}, 2000);
https://stackoverflow.com/questions/34160925
复制相似问题