使用JQuery实现定时跳转

来源:互联网 发布:网络研修社区 编辑:程序博客网 时间:2024/05/22 06:34

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebDemo.Default" %>

<!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" >
<head runat="server">
    <title></title> <script src="jquery.js" type="text/javascript"></script>
 <script language="javascript">
  $(document).ready(function() {
   function jump(count) {
    window.setTimeout(function(){
     count--;
     if(count > 0) {
      $('#num').attr('innerHTML', count);
      jump(count);
     } else {
     location.href = "WebForm1.aspx";
     }
    }, 1000);
   }
   jump(3);
  });
 </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    失败...<br />
    3秒后自动跳转。当前还剩<span id="num">3</span>秒
    </div>
    </form>
</body>
</html>

原创粉丝点击