ASP.NET實現頁面自動跳轉(經測試,在VS2008 C#環境下可通過)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<%@ 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> |