Global.asax:从iframe到父页面的Response.Redirect [英] Global.asax : Response.Redirect from iframe to parent page

查看:72
本文介绍了Global.asax:从iframe到父页面的Response.Redirect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从包含iframe的网页重定向。并从这个iframe发生了一些错误,我在global.asax页面捕获它以设置默认的Error.aspx页面。





它在iframe内重定向。请有人提出建议

提前致谢。

解决方案

是的,你可以处理如下



通过在自定义错误页面头部分中包含以下javascript / jQuery代码,它将检查它是否在iframe中加载。如果它在iframe中加载,则自定义错误页面将设置为首页。

 <   script  >  


(function(){

if(window!= window.top){//检查自定义错误页面是否在iframe中加载

window.top.location = window.location; //设置自定义错误页面位置的顶部位置

}

});

< / script >


 Response.Write(  < script language ='javascript'> self.parent.location ='login.aspx';< / script>


I want to redirect from a page which contains an iframe. and from this iframe some error occured and i am capturing it in global.asax page to set a default Error.aspx Page.


It redirects inside the iframe. Please anybody have suggestions
Thanks in advance.

解决方案

Yes you can handle as following

By having the following javascript/jQuery code within the custom error page head section, it will check whether it's loading inside an iframe. If it's loading inside an iframe, then the custom error page will set as the top page.

<script>


(function () { if (window != window.top) { //Checks whether the custom error page is loading inside an iframe window.top.location = window.location; //Set the top location to custom error page location } }); </script>


Response.Write("<script language='javascript'>self.parent.location='login.aspx';</script>")


这篇关于Global.asax:从iframe到父页面的Response.Redirect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆