我知道这是不可能的,但是想要从iFrame中执行Response.Redirect
来重定向父页面的最佳选择是什么?iFrame中的Response.Redirect(),重定向父窗口
6
A
回答
11
你不能这样做使用ASP.NET。服务器端的ASP.NET可以重定向传入的请求,并且无法知道父框架。
但是,如果你想重定向在某些服务器端状态父框架,你可以调用JavaScript从服务器这样的:
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'在客户端。
1
Response.Clear();
Header.Controls.Add(new LiteralControl(@"
<script type=""text/javascript"">
top.location = ""/Logout.aspx"";
parent.location = ""/Logout.aspx"";
</script>
"));
5
我刚刚成功地使用了下面的代码。它甚至绕过了X-Frame-Options SAMEORIGIN
,并允许重定向从一个域到另一个在iframe:
string url = "https://siteurl.com";
Response.Write("<script>top.location='"+url+"';parent.location='"+url+"';</script>");
相关问题
- 1. ASP.NET iFrame Response.Redirect父窗口
- 2. 从iFrame重定向父窗口
- 3. 从iframe动作重定向父窗口
- 4. 从iframe重定向到新窗口
- 5. Iframe/Popup重定向打开窗口
- 6. IFrame和父窗口
- 7. grails modalbox重定向回父窗口
- 8. 向父窗口注入iframe javascript代码
- 9. 从iFrame重定向父级
- 10. Iframe payone重定向父母
- 11. 如何关闭弹出窗口并重定向父窗口
- 12. 关闭子窗口,重定向父窗口
- 13. 关闭弹出窗口并重定向到父窗口在Struts2
- 14. 从iframe的Javascript父页重定向
- 15. iframe中的链接更改父窗口
- 16. iframe中的location.hash滚动父窗口
- 17. 从父窗口和父窗口提交功能给父窗口和iframe
- 18. Response.Redirect不总是重定向
- 19. jQuery iframe弹出窗口和父窗体
- 20. 使用iframe时父级重定向
- 21. 如何防止IFRAME的重定向顶级窗口
- 22. 在父窗口中调用iframe函数
- 23. 帮我重新中心ModalPopup一个iframe中时iframe的父窗口滚动
- 24. 模态窗口重定向
- 25. JavaScript重定向 - 新窗口
- 26. 子窗口重定向
- 27. 为什么Response.Redirect关闭我的浏览器窗口而不是重定向?
- 28. 如何打开iframe中的重定向页面作为ASP.NET中父窗口中的新选项卡打开?
- 29. Asp.Net中的新窗口中的Response.Redirect()
- 30. 单击ModalPopup的IFrame改变父窗口
注意,框架和父框架文件的域将需要匹配,以避免访问被拒绝被大多数浏览器抛出错误。 – Chris
如果我的父母在框架中有另一个域名? – Kiquenet