JS在一定時(shí)間內(nèi)跳轉(zhuǎn)頁面及各種刷新頁面的實(shí)現(xiàn)方法

字號(hào):


    這篇文章主要介紹了JS在一定時(shí)間內(nèi)跳轉(zhuǎn)頁面及各種刷新頁面的實(shí)現(xiàn)方法的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    1.js 代碼:
    <SCRIPT LANGUAGE="JavaScript">
    var time = 5; //時(shí)間,秒
    var timelong = 0;
    function diplaytime(){ //時(shí)間遞減
    document.all.his.innerHTML = time -timelong ;
    timelong ++;
    }
    function redirect(){ //跳轉(zhuǎn)頁
    //history.back();
    window.location.href="Category-list";//指定要跳轉(zhuǎn)到的目標(biāo)頁面
    }
    timer=setInterval('diplaytime()', 1000);//顯示時(shí)間
    timer=setTimeout('redirect()',time * 1000); //跳轉(zhuǎn)
    </SCRIPT>
    2.頁面引用:
    <DIV ALIGN="CENTER" >
    如果你不執(zhí)行任何操作,系統(tǒng)會(huì)在5秒后自動(dòng)返回!
    </DIV>
    <DIV ALIGN="CENTER" id="his">
    5秒鐘后自動(dòng)返回.....
    </DIV>
    javascript/js 自動(dòng)刷新頁面和頁面跳轉(zhuǎn)的實(shí)現(xiàn)方法
    1)
    <meta http-equiv="refresh"content="10;url=跳轉(zhuǎn)的頁面">
    10表示間隔10秒刷新一次
    2)
    <script language=''javascript''>
    window.location.reload(true);
    </script>
    如果是你要刷新某一個(gè)iframe就把window給換成frame的名字或ID號(hào)
    3)
    <script language=''javascript''>
    window.navigate("本頁面url");
    </script>
    4>
    function abc()
    {
    window.location.href="/blog/window.location.href";
    setTimeout("abc()",10000);
    }
    刷新本頁:
    Response.Write("<script language=javascript>window.location.href=window.location.href;</script>")
    刷新父頁:
    Response.Write("<script language=javascript>opener.location.href=opener.location.href;</script>")
    轉(zhuǎn)到指定頁:
    Response.Write("<script language=javascript>window.location.href='yourpage.aspx';</script>")
    刷新頁面實(shí)現(xiàn)方式總結(jié)(HTML,ASP,JS)'by aloxy
    定時(shí)刷新:
    1,
    <script>setTimeout("location.href='url'",2000)</script>
    說明:url是要刷新的頁面URL地址
    2000是等待時(shí)間=2秒,
    2,<meta name="Refresh" content="n;url">
    說明:
    n is the number of seconds to wait before loading the specified URL.
    url is an absolute URL to be loaded.
    n,是等待的時(shí)間,以秒為單位
    url是要刷新的頁面URL地址
    3,<%response.redirect url%>
    說明:一般用一個(gè)url參數(shù)或者表單傳值判斷是否發(fā)生某個(gè)操作,然后利用response.redirect刷新。
    4,刷新框架頁
    〈script language=javascript>top.leftFrm.location.reload();parent.frmTop.location.reload();</script〉
    彈出窗體后再刷新的問題
    Response.Write("<script>window.showModalDialog('../OA/SPCL.aspx',window,'dialogHeight: 300px; dialogWidth: 427px; dialogTop: 200px; dialogLeft: 133px')</script>");//open
    Response.Write("<script>document.location=document.location;</script>");
    在子窗體頁面代碼head中加入<base target="_self"/>
    刷新的內(nèi)容加在 if (!IsPostBack)中在框架頁中右面刷新左面
    //刷新框架頁左半部分
    Response.Write("<script language=javascript>");
    Response.Write("parent.left.location.href='PayDetailManage_Left.aspx'");
    Response.Write("</script>");
    頁面定時(shí)刷新功能實(shí)現(xiàn)
    有三種方法:
    1,在html中設(shè)置:
    <title>xxxxx</title>之後加入下面這一行即可!
    定時(shí)刷新:<META HTTP-EQUIV="Refresh" content="10">
    10代表刷新間隔,單位為秒
    2.jsp
    <% response.setHeader("refresh","1"); %>
    每一秒刷新一次
    3.使用javascript.:
    <script language="javascript">
    setTimeout("self.location.reload();",1000);
    <script>
    一秒一次
    頁面自動(dòng)跳轉(zhuǎn):
    1,在html中設(shè)置:
    <title>xxxxx</title>之後加入下面這一行即可!
    定時(shí)跳轉(zhuǎn)并刷新:<meta http-equiv="refresh" content="20;url=http://自己的URL">,其中20指隔20秒后跳轉(zhuǎn)到http://自己的URL
    頁面。
    點(diǎn)擊按鈕提交表單后刷新上級窗口
    A窗口打開B窗口
    然后在B里面提交數(shù)據(jù)至C窗口