现在的位置: 首页 > 综合 > 正文

asp.net中倒计时自动跳转页面的实现方法(使用javascript)

2012年10月10日 ⁄ 综合 ⁄ 共 857字 ⁄ 字号 评论关闭

首先,先建立一个用于跳转的页面,代码如下。

复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoginTiao.aspx.cs" Inherits="LoginTiao" %>

<!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 id="Head1" runat="server">
<title>跳转页面</title>
<script type="text/javascript">
var i = 5;
window.onload=function page_cg()
{
document.getElementById("time").innerText = i;
i--;
if(i==0)
{
window.location.href("XXXXX/Home.aspx");
}
setTimeout(page_cg,1000);
}
</script>

</head>
<body>
<form id="form1" runat="server">
<div style="font-size:small;">
密码修改成功,请牢记!
<br />
秒后自动跳到系统<a href="XXXXX/Home.aspx">首页面</a>...还剩<span id="time" style="font-weight:bold;color: blue">5</span>秒!
<br />
或者返回<a href="Login.aspx">登陆页面</a>...
</div>
</form>
</body>
</html>

然后在要引用的页面打向我们刚刚建立的页面即可

Response.Redirect("LoginTiao.aspx");

代码简单就不贴图了!

抱歉!评论已关闭.