第一:
    Response.Redirect( Request.Url.ToString( ) );
第二:
    Response.Write( "<script language=javascript>window.location.href=document.URL;</script>" );
第三:
    Response.AddHeader( "Refresh","0" );
第四:
    Response.Write( "
    <script language=javascript>window.location.reload( );
    </script>" );
第五:(需替换<>)
<script><!--
var limit="3:00"
if ( document.images )
{
    var parselimit=limit.split( ":" )parselimit=parselimit[0]*60+parselimit[1]*1
}
function beginrefresh( )
{
    if ( !document.images )returnif ( parselimit==1 )window.location.reload( )else
    {
        parselimit-=1curmin=Math.floor( parselimit/60 )cursec=parselimit%60if ( curmin!=0 )curtime=curmin+"分"+cursec+"秒后重刷本页!"elsecurtime=cursec+"秒后重刷本页!"window.status=curtimesetTimeout( "beginrefresh( )",1000 )
    }
}
window.onload=beginrefresh//-->  </script>
<DIV style="Z-INDEX: 102;
LEFT: 408px;
POSITION: absolute;
TOP: 232px" ms_positioning="text2D">
<P><FONT size="3">自动刷新页面</FONT></P>
</DIV>
第六:
<meta http-equiv="refresh" content="300;
url=target.html">
注:
用window.location.href实现刷新另个框架页面方法:
如:index.htm页面中有二个框架,分别为 frameLeft和frameRight,在frameRight页面中执行服务器端代码后刷新frameLeft中的页面。

先前最常见的是注册之后,自动刷新登陆框,让登陆框换成已登陆页面,只要在注册成功的代码之后加上一段,即可以实现刷新另个框架的页面。代码如下:

Response.Write("<script language=javascript>alert('恭喜您,注册成功!')</script>");
Response.Write("<script language=javascript>window.parent.frameLeft.location.href='main.html'</script>");

在写ASP.Net程序的时候,我们经常遇到跳转页面的问题,我们经常使用Response.Redirect ,如果客户要在跳转的时候使用提示,这个就不灵光了,如:
Response.Write("<script>alert('恭喜您,注册成功!');</script>");
Response.Redirect("main.html");
这时候我们的提示内容没有出来就跳转了,和Response.Redirect("main.html");没有任何区别。

这时我们采用下面代码试验一下:
Response.Write("<script language=javascript>alert('恭喜您,注册成功!')</script>");
Response.Write("<script language=javascript>window.location.href='main.html'</script>");
这个即实现了我们的要求,在提示后,跳转页面。
最重要的是window.location.href 语句可以实现一个框架的页面在执行服务器端代码后刷新另一个框架的页面(Response.Redirect无法达到.
posted on 2009-10-03 06:06  freedom831215  阅读(491)  评论(0)    收藏  举报