html-javascript前端页面刷新重载的方法汇总

编程知识 行业动态 更新时间:2024-06-13 00:17:49

一、javascript页面刷新重载的方法:

<a href="javascript:location.reload();">点击重新载入页面</a>
<a href="javascript:history.go(0);">点击重新载入页面</a>
<a href="javascript:location=location;">点击重新载入页面</a>
<a href="javascript:location=location.href;">点击重新载入页面</a>
<a href="javascript:location.replace(location);">点击重新载入页面</a>
<a href="javascript:location.replace(location.href);">点击重新载入页面</a>
<a href="javascript:location.assign(location);">点击重新载入页面</a>
<a href="javascript:location.assign(location.href);">点击重新载入页面</a>
<!--// 以下只支持ie -->
<a href="javascript:document.URL=location.href;">点击重新载入页面</a>
<a href="javascript:navigate(location);">点击重新载入页面</a>
<a href="javascript:document.execCommand('Refresh');">点击重新载入页面</a>
<!--// 以上只支持ie -->

二、html链接重新载入方法

<!--// 以下不支持ie -->
<a href="">点击重新载入页面</a>
<!--// 以上不支持ie -->
<a href="页面本身">点击重新载入页面</a>

三、自动刷新页面的方法

<meta http-equiv="refresh" content="20">  //代码放在head中,每隔20秒钟刷新一次

<meta http-equiv="refresh" content="20;url=http://www.haorooms">  //20秒之后页面跳转到haorooms中,通常运用到404页面

//js自动刷新
function myrefresh()

{

       window.location.reload();

}

setTimeout('myrefresh()',1000); //指定1秒刷新一次

三、返回上一页和下一页的方法

history.go(-1)//返回上一页(括号中写-2代表返回上两页)

history.back()//返回上一页

window.history.forward()  //返回下一页

javascript前端页面刷新重载及历史,暂时就想到这么多!还有其他方法的话,小伙伴们可以留言啊!共同交流!

更多推荐

html-javascript前端页面刷新重载的方法汇总

本文发布于:2023-03-25 20:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/40e8d8b07ff92f12127f9ab71b60207d.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:页面   方法   html   javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!