在asp.net 中 如何在登录成功后2秒内自动跳转到登录前的页面
response.rdirect(HttpContext.Current.Request.Url.PathAndQuery);
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Register_Succeed.aspx.cs" Inherits="Register_Succeed" %>
<!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>
<link href="css/common.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#register_div
{
}
#goto_div
{
height:40px;
padding-top:30px;
text-align:center;
}
</style>
<script type="text/javascript">
function goto_HomePage()
{
location.href = "default.aspx";
}
function time()
{
setTimeout(goto_HomePage,3000);
}
</script>
</head>
<body onload="time();">
<form id="form1" runat="server">
<!-- 顶部 -->
<div class="top_div">
</div>
<!-- 中部 -->
<div class="main_div">
<div id="register_div">
登陆成功
</div>
<div id="goto_div">
<asp:Literal ID="Literal1" runat="server"></asp:Literal>,系统将在3秒后跳到
<a href="Default.aspx" title="赢在校园首页">赢在校园首页</a>
</div>
</div>
<!-- 中部 -->
<div class="bottom_div">
</div>
</form>
</body>
</html>
直接在html页面里加代码也可以
<META http-equiv="Refresh" content="5;url=<%=url%>">
5是等待的时间,url是要条状的页面
<script language="javascript">
function returnUrl()
{
window.location.href="Reg.aspx";
}
setInterval(returnUrl,2000);
</script>
或
<script language="javascript">
var Sec=2;
function Start()
{
Sec=Sec-1;
if(Sec==0)
{ window.location.href="WebForm1.aspx";
}
else
{
document.Form1.elements["SecondTime"].value=Sec;
setTimeout("Start()",1000);
}
}
在body标记里添加
<body onload="Start()" MS_POSITIONING="GridLayout">