我们在写前端页面的时候,经常会使用到刷新当前页面的功能,这篇我们来介绍HTML页面刷新的三种方法。
第一种方法:reload()
reload()方法用于刷新当前文档,类似于你浏览器上的刷新页面按钮。
代码如下:
location.reload();
第二种方法:replace()
replace() 方法是用一个新文档取代当前文档。
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>剑鱼论坛(jianyuluntan.com)</title>
<script>
function replaceFun()
{
window.location.replace("http://jianyuluntan.com")
}
</script>
</head>
<body>
<input type="button" value="载入新的文档替换当前页面">
</body>
</html>
第三种方法:meta
这种方法不需要使用JavaScript,只需要在HTML文档里面的head区域里面加下面的代码:
<meta http-equiv="refresh" content="5">
这个是用于页面自动刷新的,其中的5指每隔5秒刷新一次页面。
论坛主帖
288
论坛跟帖
316
在线访客
0
今日主帖
0
今日跟帖
0
今日注册
0
242
http://jianyuluntan.com/gentie.html
http://jianyuluntan.com/postzan.html
http://jianyuluntan.com/postcai.html
http://jianyuluntan.com/postshoucang.html
http://jianyuluntan.com/gentiezan.html
http://jianyuluntan.com/gentiecai.html
http://jianyuluntan.com/huifu.html
http://jianyuluntan.com/xiugai.html
http://jianyuluntan.com/shanchugentie.html
1
cmVsZWFzZV8w
0
© 2019 - 2024 剑鱼论坛 版权所有
Powered by JianYuLunTan
976666861
http://jianyuluntan.com/feedback.html
http://jianyuluntan.com/qiandao.html
http://jianyuluntan.com/denglu.html
0
http://jianyuluntan.com/adenglu.html
0