沈阳手机网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

沈阳手机网手机维修培训中心Apple手机报价沈阳二手笔记本报价

二手手机回收

沈阳手机靓号DJ音乐 最好听的DJ
查看: 982|回复: 0

网站404页面3秒后跳到首页的实例代码

[复制链接]
发表于 2014-3-18 09:27:45 | 显示全部楼层 |阅读模式
网站会有有错误404页面,当页面不存存时就会提示,然后过几秒就会自动跳到首页了,下面我来给大家举一个404错误页面跳到首页实例,各位可参考,有需要的朋友可以参考一下
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

  2. <html>

  3. <head>

  4. <meta http-equiv="Content-Type" content="text/html; charset=GBK">

  5. <title>404 Not Found</title>

  6. </head>

  7. <body>

  8.   <h1>找不到指定的页面</h1>

  9.   <span id="totalSecond">3</span>秒后自动返回

  10. </body>

  11. <script language="javascript" type="text/javascript">

  12. <!--

  13.     var second = document.getElementById('totalSecond').textContent;

  14.      if (navigator.appName.indexOf("Explorer") > -1)  //判断是IE浏览器还是Firefox浏览器,采用相应措施取得秒数

  15.     {

  16.          second = document.getElementById('totalSecond').innerText;

  17.      } else

  18.      {

  19.          second = document.getElementById('totalSecond').textContent;

  20.      }

  21.      setInterval("redirect()", 1000);  //每1秒钟调用redirect()方法一次

  22.     function redirect()

  23.      {

  24.          if (second < 0)

  25.          {

  26.              location.href = 'http://要跳转的网站';

  27.          } else

  28.          {

  29.              if (navigator.appName.indexOf("Explorer") > -1)

  30.              {

  31.                  document.getElementById('totalSecond').innerText = second--;

  32.              } else

  33.              {

  34.                  document.getElementById('totalSecond').textContent = second--;

  35.              }

  36.          }

  37.      }

  38. -->

  39. </script>

  40. </html></td>

  41.     </tr>

  42.   </table>
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|沈阳手机网 ( 辽ICP备11004416号 )

GMT+8, 2024-5-17 14:46 , Processed in 0.021397 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表