ASP.Net中使用 window.location.href 实现页面跳转(转自:永恒的回忆)
2008-12-15 11:44
696 查看
在写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无法达到,至少我没有发现):
如: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>");
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无法达到,至少我没有发现):
如: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中使用 window.location.href 实现页面跳转
- 用window.location.href实现页面跳转
- location.href、parent.location.href、top.location.href、 window.open实现页面跳转
- 使用window.location.href跳转页面在IE和FF浏览器中路径不一致的问题总结
- asp.net中倒计时自动跳转页面的实现方法(使用javascript)
- 解决在chrome浏览器使用js的window.location.href跳转页面失败的问题
- location.href、parent.location.href、top.location.href、 window.open实现页面跳转
- 用window.location.href实现页面跳转
- ASP.NET页面内跳转无刷新-- window.location.hash
- 用window.location.href实现页面跳转
- location.href、parent.location.href、top.location.href、 window.open实现页面跳转
- 用window.location.href实现页面跳转
- asp.net中倒计时自动跳转页面的实现方法(使用javascript)
- location.href、parent.location.href、top.location.href、 window.open实现页面跳转
- ASP.NET jQuery 实例11 通过使用jQuery validation插件简单实现用户登录页面验证功能
- ASP.NET(C#)实现页面计时(定时)自动跳转
- js 中实现页面跳转的方法(window.location和window.open的区别)
- Asp.net中实现页面跳转的三种方法比较
- ASP.NET MVC使用SSI来实现页面静态化
- js页面跳转(window.location.href)乱码问题