js刷新頁面和跳轉

javascript返回上一頁:

一、返回上一頁 history.go(-1); 返回上兩個頁面 history.go(-2);javascript

<a href="javascript:history.go(-1);">上一頁</a>java

二、history.back().ui

三、window.history.forward() 返回下一頁url

四、window.history.go(返回第幾頁,也能夠是url)spa

五、window.location.href=url;code

js刷新頁面的幾種方法:

一、history.go(0);blog

二、window.location.href=當前頁面url;ip

三、location=location;it

四、location.replace(location);io

五、location.assign(location);

六、window.navigate(location);

七、document.URL=location.href

自動刷新頁面的方法:

一、頁面自動刷新:在<head>標籤中加入

<meta http=-equiv="refresh" content="20">其中20指每隔20s刷新一次

二、頁面自動跳轉:在<head>標籤中加入

<meta http=-equiv="refresh" content="20;url="http:www.baidu.com">其中20指20s後跳轉到http://www.baidu.com

三、頁面自動刷新,js

複製代碼
<script language="JavaScript">
    function myrefresh()
    {
           window.location.reload();
    }
    setTimeout('myrefresh()',1000); //指定1秒刷新一次
</script>
相關文章
相關標籤/搜索