Jcat
          寵辱不驚,閑看庭前花開(kāi)花落~~
          posts - 173,comments - 67,trackbacks - 0
          功能:5秒后,自動(dòng)跳轉(zhuǎn)到同目錄下的02view.html文件
          ?
          1)html的實(shí)現(xiàn)
          <head>
          <meta?http-equiv="refresh"?content="5;url=02view.html">
          </head>

          優(yōu)點(diǎn):簡(jiǎn)單
          缺點(diǎn):Struts Tiles中無(wú)法使用
          ?
          2)javascript的實(shí)現(xiàn)
          <script?language="javascript"?type="text/javascript">
          ?? setTimeout(
          "javascript:location.href='02view.html'",?5000);?
          </script>

          優(yōu)點(diǎn):靈活,可以結(jié)合更多的其他功能
          缺點(diǎn):受到不同瀏覽器的影響
          ?
          3)結(jié)合了倒數(shù)的javascript實(shí)現(xiàn)(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='02view.html';
          }
          </script>

          優(yōu)點(diǎn):更人性化
          缺點(diǎn):firefox不支持(firefox不支持span、div等的innerText屬性)
          ?
          3')結(jié)合了倒數(shù)的javascript實(shí)現(xiàn)(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?=?'02view.html';
          ????}
          </script>

          4)解決Firefox不支持innerText的問(wèn)題
          <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?
          =?'02view.html';
          ????????}?
          else
          ????????{
          ????????????
          if?(navigator.appName.indexOf("Explorer")?>?-1)
          ????????????{
          ????????????????document.getElementById('totalSecond').innerText?
          =?second--;
          ????????????}?
          else
          ????????????{
          ????????????????document.getElementById('totalSecond').textContent?
          =?second--;
          ????????????}
          ????????}
          ????}
          </script>
          posted on 2006-11-22 17:20 Jcat 閱讀(16884) 評(píng)論(2)  編輯  收藏 所屬分類(lèi): Java

          FeedBack:
          # re: 一些頁(yè)面自動(dòng)跳轉(zhuǎn)的實(shí)現(xiàn)[未登錄](méi)
          2008-07-19 10:25 | jimmy
          好東東,謝謝樓主分享,解決了我的問(wèn)題。  回復(fù)  更多評(píng)論
            
          # re: 一些頁(yè)面自動(dòng)跳轉(zhuǎn)的實(shí)現(xiàn)[未登錄](méi)
          2010-12-30 12:42 | jake
          很好,謝謝LZ總結(jié)了。  回復(fù)  更多評(píng)論
            
          主站蜘蛛池模板: 灵石县| 炎陵县| 图片| 新蔡县| 义乌市| 建始县| 文昌市| 洱源县| 海丰县| 灵川县| 九龙坡区| 荃湾区| 义马市| 江津市| 河南省| 光山县| 常州市| 邵阳市| 望都县| 桃源县| 长春市| 论坛| 瑞丽市| 福清市| 香格里拉县| 宣汉县| 冀州市| 屏南县| 盐边县| 清苑县| 阜阳市| 乐昌市| 江川县| 繁峙县| 云和县| 明溪县| 沛县| 安乡县| 广丰县| 肇源县| 张家口市|