浏览器刷新页面

浏览器刷新的四种方法:

方法一: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>


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值