Response.Redirect的()在iFrame中,重定向父窗口 [英] Response.Redirect() in iFrame, redirect parent window

查看:3569
本文介绍了Response.Redirect的()在iFrame中,重定向父窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是不可能的,但什么是想从一个iFrame做的Response.Redirect ,父页面重定向的最佳替代品?

I know this isn't possible, but what is the best alternative for wanting to do Response.Redirect from an iFrame, to redirect the parent page?

推荐答案

您无法使用ASP.NET做到这一点。在服务器端ASP.NET可以重定向传入的请求,并不能知道一个父框架。

You can not do this using ASP.NET. ASP.NET on server side can redirect incoming request and can't know about a parent frame.

但是,如果你想重定向在某些服务器端状态父框架可以从这样的服务器调用JavaScript:

But if you want to redirect parent frame on some server side condition you can call JavaScript from server like this:

protected void Page_Load(object sender, EventArgs e) {
   ClientScriptManager.RegisterClientScriptBlock(this.GetType(), 
       "RedirectScript", "window.parent.location = 'http://yoursite.com'", true);
}

当然,你可以使用简单的JavaScript window.parent.location ='http://yoursite.com在客户端。

And of course you can use simple JavaScript window.parent.location = 'http://yoursite.com' on client side.

这篇关于Response.Redirect的()在iFrame中,重定向父窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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