zoukankan      html  css  js  c++  java
  • JavaScript实现页面跳转

    1、源码如下

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK">
    <title>404 Not Found</title>
    </head>
    <body>
     <h1>找不到指定的页面</h1>
     <span id="totalSecond">3</span>秒后自动返回
    </body>
    <script language="javascript" type="text/javascript">
    <!--
        var second = document.getElementById('totalSecond').textContent;
        if (navigator.appName.indexOf("Explorer") > -1)  //判断是IE浏览器还是Firefox浏览器,采用相应措施取得秒数
        {
            second = document.getElementById('totalSecond').innerText;
        } else
        {
            second = document.getElementById('totalSecond').textContent;
        }
        setInterval("redirect()", 1000);  //每1秒钟调用redirect()方法一次
        function redirect()
        {
            if (second < 0)
            {
                location.href = 'http://www.baidu.com';
            } else
            {
                if (navigator.appName.indexOf("Explorer") > -1)
                {
                    document.getElementById('totalSecond').innerText = second--;
                } else
                {
                    document.getElementById('totalSecond').textContent = second--;
                }
            }
        }
    -->
    </script>
    </html></td>
    	  </tr>
    	</table>
    2、运行结果

    (1)初始化


    (2)跳转后


  • 相关阅读:
    Java虚拟机:二、Java内存区域
    Filter模块插件的详细介绍
    Input模块插件的详细介绍
    Logstash的简单介绍
    Logstash的下载安装
    安装Ruby和logstash插件
    Kibana安装与web界面
    ElasticSearch的下载安装
    Flink项目点 pom文件
    IDEA的配置
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13315660.html
Copyright © 2011-2022 走看看