【總結】刷新和上一步下一步

一、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>


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

history.go(-1)//返回上一頁(括號中寫-2代表返回上兩頁)

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

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


四、自動刷新頁面的方法

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

<meta http-equiv="refresh" content="20;url=http://www.haorooms.com">  //20秒之後頁面跳轉到haorooms中,通常運用到404頁面

//js自動刷新
function myrefresh()

{

       window.location.reload();

}

setTimeout('myrefresh()',1000); //指定1秒刷新一次
轉載自:http://www.haorooms.com/post/js_refrash













發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章