【JavaScript&jQuery】5秒跳转

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
    <head>  
        <title>404错误页面</title>  
        <meta charset="utf-8">  
        <meta http-equiv="pragma" content="no-cache">  
        <meta http-equiv="cache-control" content="no-cache">  
        <meta http-equiv="expires" content="0">  
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">  
        <meta http-equiv="description" content="This is my page">  
        <link rel="stylesheet" href="css/bootstrap.min.css" />  
        <style>  
            body{background: url(images/404.jpg);background-size: cover;}  
            .error{ 100px;margin: 0 auto;}  
            #count b{font-size: 65px;color:#BF3333;}  
        </style>  
    </head>  
  
    <body>  
        <div class="error">  
            <span id = "count"><b> 5 </b></span>  
            <a class="btn btn-warning" href="index.html">点击返回</a>  
        </div>  
        <script type="text/javascript" src="js/jquery-1.6.4.js" ></script>  
        <script type="text/javascript">  
            $(function() {  
                var count = 5;  
                setInterval(function() {  
                    count--;  
                    if (count <= 0) window.location.href = "index.html";  
                    $("#count").html("<b>" + count + "</b>");  
                }, 1000);   
            });  
        </script>  
    </body>  
  
</html>  
原文地址:https://www.cnblogs.com/dflmg/p/6382308.html