细谈JS刷新页面常用方法有哪些

 我来答
约定20125
2018-08-11 · TA获得超过1.5万个赞
知道大有可为答主
回答量:1.1万
采纳率:96%
帮助的人:2755万
展开全部
js常见的几种页面刷新方法如下:
1 history.go(0);
2 location.reload();
3 location=location;
4 location.assign(location);
5 document.execCommand(‘Refresh‘);
6 window.navigate(location);
7 location.replace(location);
8 document.URL=location.href;
以上几种方法都是单纯的属性当前页面,如果框架页面中有子页面,只想刷新子页面的时候,可以用以下方法:
top.location.reload(); 刷新整页
self.location.reload(); 刷新本页
window.location.href="自定义页面地址";
自动刷新页面的方法:
在<head>标签中加入<meta http-equiv="refresh" content="10">
其中content是时间间隔,每10s刷新一次
在body中添加onload="opener.location.reload()",即<body onload="opener.location.reload()"> 为页面启动时刷新
在body中添加onUnload="opener.location.reload()",即<bodyonUnload="opener.location.reload()"> 为页面关闭时刷新
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式