ASP.NET实现页面自动跳转(经测试,在VS2008 C#环境下可通过)

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_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 type="text/javascript">
        var i = 5;
        
        // 获取登录事件,并处理自动跳转
        window.onload = function JumpPage() 
        {
            document.getElementById("time").innerText = i;
            
            // 计时为0后,立即跳转
            i--;
            if (i < 0) 
            {
                location.replace("http://www.baidu.com");
            }

            setTimeout("JumpPage()", 1000);
        }
    </script>
</head>

<body>
    <form id="form2" runat="server">
        <div id="AutoJumpPage">
            欢迎您,本页将在<span id="time" style="color: #FF0000"></span>秒后自动跳转至<a href="http://www.baidu.com">百度</a>
            <br /><br />
            如需立即跳转,请直接点击 <a href="http://www.baidu.com" style="color: #FF00FF">立即跳转>></a>
        </div>
    </form>
</body>

</html>

 

 

原文: ASP.NET(C#)实现页面计时(定时)自动跳转