浏览器刷新页面

浏览器刷新的四种方法:

方法一:head中添加meta标签

  每5秒刷新一次,5秒后跳转到指定链接

<meta http-equiv="refresh" content="5" />
<meta http-equiv="refresh" content="5;url=https://www.baidu.com/" />

方法二:刷新网页

window.location.reload();//刷新当前页
window.location.replace("https://www.baidu.com/");//指定刷新位置
window.location.href='https://www.baidu.com/';
document.execCommand('Refresh');

返回并刷新页面:

location.replace(document.referrer);
document.referrer //前一个页面的URL

方法三:利用定时任务

function domRefresh() {
    window.location.reload();
}

setTimeout('domRefresh();', 1000);  //单位为毫秒*/

方法四:按钮版本

<p><input type="button" onclick="javascript:location.reload();" value="刷新当前页面"></p>

<a title="刷新" class="btn btn-success radius r" style="line-height: 1.6em; margin-top: 3px;" href="javascript:location.replace(location.href);">刷新</a>


 

猜你喜欢

转载自blog.csdn.net/qq_36521848/article/details/106204718