js 刷新当前页面的三种方式

1、reload() 方法

reload()方法用于刷新当前文档。
reload() 方法类似于你浏览器上的刷新页面按钮。

location.reload();

2、replace() 方法

replace() 方法可用一个新文档取代当前文档。。和href类似,就是一个跳转。不过没有后退。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
<script>
function replaceDoc()
{
    window.location.replace("http://www.runoob.com")
}
</script>
</head>
<body>

<input type="button" value="载入新文档替换当前页面" onclick="replaceDoc()">

</body>
</html> 

3、meta中也只页面自动刷新

<meta http-equiv="refresh" content="5">

注:equiv == equivalent,为等价的意思。

转自:http://www.runoob.com/w3cnote/js-refresh-current-page.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容