【发布时间】:2011-02-16 04:50:49
【问题描述】:
我遇到了从 IFrame 中的按钮重定向我的 asp 页面的情况。
按钮点击事件中的Response.Redirect重定向IFrame而不是整个页面。
谢谢, 毗湿奴
【问题讨论】:
标签: c# asp.net iframe response.redirect
我遇到了从 IFrame 中的按钮重定向我的 asp 页面的情况。
按钮点击事件中的Response.Redirect重定向IFrame而不是整个页面。
谢谢, 毗湿奴
【问题讨论】:
标签: c# asp.net iframe response.redirect
您可以将target="_top" 添加到html <form> 元素,或使用javascript 重定向window.top.location = '/path'。
如果您有多个 iframe 页面,您可能想要创建一个通用页面,我们称之为FrameRedirector.aspx。将此代码放在正文中:
<script type="text/javascript">
window.top.location = '<%=Server.UrlDecode(Request.QueryString["url"])%>';
</script>
然后,将Response.Redirect 代码替换为
string redirect = "/path/to/redirect.aspx?foo=bar";
Response.Redirect("~/FrameRedirector.aspx?url=" + Server.UrlEncode(redirect));
【讨论】: