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

如题所述

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()"> 为页面关闭时刷新
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网