純html網頁重定向與跳轉

    網頁定時跳轉至指定鏈接

    演示:

    演示

    提取碼:無
    解壓碼:無

    來源于:

    https://www.cnblogs.com/aszx0413/articles/1886819.html

    實現代碼:

    <html>
    <head>
    <meta charset="utf-8">
        <meta http-equiv="refresh" content="1; url=https://www.dongbd.com/">
    <title>定時跳轉</title>
    </head>
     
    <body>
        <h2>此頁面將在1秒后跳轉</h2>
    </body>
    </html>

    下面列了五個例子來詳細說明,這幾個例子的主要功能是:在5秒后,自動跳轉到同目錄下的hello.html(根據自己需要自行修改)文件。

    1) html的實現

    <head>
    <!-- 以下方式只是刷新不跳轉到其他頁面 -->
    <meta?http-equiv="refresh" content="10">
    <!-- 以下方式定時轉到其他頁面 -->
    <meta?http-equiv="refresh" content="5;url=hello.html"> 
    </head>
    

    優點:簡單

    缺點:Struts Tiles中無法使用

    2) javascript的實現

    <script language="javascript"?type="text/javascript"> 
    // 以下方式直接跳轉
    window.location.href='hello.html';
    // 以下方式定時跳轉
    setTimeout("javascript:location.href='hello.html'", 5000); 
    </script>
    

    優點:靈活,可以結合更多的其他功能

    缺點:受到不同瀏覽器的影響

    3) 結合了倒數的javascript實現(IE)

    <span?id="totalSecond">5</span>
    <script?language="javascript" type="text/javascript"> 
    var second = totalSecond.innerText; 
    setInterval("redirect()", 1000); 
    function redirect(){ 
    totalSecond.innerText=--second; 
    if(second<0) location.href='hello.html'; 
    } 
    </script>
    

    優點:更人性化

    缺點:firefox不支持(firefox不支持span、div等的innerText屬性)

    3′) 結合了倒數的javascript實現(firefox)

    <script language="javascript"?type="text/javascript"> 
    var?second = document.getElementById('totalSecond').textContent; 
    setInterval("redirect()", 1000); 
    function?redirect() 
    { 
    document.getElementById('totalSecond').textContent = --second; 
    if?(second < 0) location.href = 'hello.html'; 
    } 
    </script>
    

    4) 解決Firefox不支持innerText的問題

    <span?id="totalSecond">5</span>
    <script?language="javascript" type="text/javascript"> 
    if(navigator.appName.indexOf("Explorer") > -1){ 
    document.getElementById('totalSecond').innerText = "my text innerText"; 
    } else{ 
    document.getElementById('totalSecond').textContent = "my text textContent"; 
    } 
    </script>
    

    5) 整合3)和3′)

    <span?id="totalSecond">5</span>
    ?
    <script?language="javascript" type="text/javascript"> 
    var second = document.getElementById('totalSecond').textContent; 
    ?
    if (navigator.appName.indexOf("Explorer") > -1)? { 
    ????second = document.getElementById('totalSecond').innerText; 
    } else { 
    ????second = document.getElementById('totalSecond').textContent; 
    } 
    ?
    setInterval("redirect()", 1000); 
    function redirect() { 
    if (second < 0) { 
    ????location.href = 'hello.html'; 
    } else { 
    ????if (navigator.appName.indexOf("Explorer") > -1) { 
    ????????document.getElementById('totalSecond').innerText = second--; 
    ????} else { 
    ????????document.getElementById('totalSecond').textContent = second--; 
    ????} 
    } 
    } 
    </script>
    
    插件

    Easy digital down loads - 用WordPress銷售數字產品

    2019-9-17 0:00:58

    隨記

    文派博客 - 國內版優化WordPress博客平臺

    2020-11-22 17:28:55

    ??
    Npcink上的部份代碼及教程來源于互聯網,僅供網友學習交流,若您喜歡本文可附上原文鏈接隨意轉載。
    無意侵害您的權益,請發送郵件至 1355471563#qq.com 或點擊右側 私信:Muze 反饋,我們將盡快處理。
    0 條回復 A文章作者 M管理員
      暫無討論,說說你的看法吧
    ?
    個人中心
    購物車
    優惠劵
    今日簽到
    有新私信 私信列表
    搜索
    主站蜘蛛池模板: 美日韩一区二区三区| 成人国产精品一区二区网站| 无码人妻少妇色欲AV一区二区| 成人精品视频一区二区三区不卡| 亚洲中文字幕丝袜制服一区 | 狠狠综合久久av一区二区| 久久青青草原一区二区| 国产激情一区二区三区四区 | 亚洲AV香蕉一区区二区三区| 精品少妇人妻AV一区二区| 国产丝袜一区二区三区在线观看| 国产在线一区二区三区av| 中文无码精品一区二区三区| 精品无码一区二区三区亚洲桃色| 伊人色综合一区二区三区影院视频| 午夜视频在线观看一区二区| 久久国产精品一区| 人妻体体内射精一区二区| 无码人妻精一区二区三区| 国产精品毛片a∨一区二区三区| 亚洲AV本道一区二区三区四区| 中文字幕av人妻少妇一区二区| 精品一区二区三区在线观看l | 亚洲一区无码精品色| 国产成人AV一区二区三区无码 | 久久精品视频一区二区三区| 中日韩精品无码一区二区三区| 无码毛片一区二区三区视频免费播放 | 国产精品成人一区二区三区| 色狠狠色噜噜Av天堂一区| 在线播放偷拍一区精品| 中文字幕一区二区三区视频在线| 91精品一区二区三区在线观看| 波多野结衣av高清一区二区三区| 久久精品动漫一区二区三区| 日本在线视频一区| 日本一区二区三区爆乳| 一本AV高清一区二区三区| 日本一区二三区好的精华液| 不卡一区二区在线| 国产一区二区三区免费在线观看 |