我遇到了从 IFrame 中的按钮重定向我的 asp 页面的情况。
按钮单击事件中的 Response.Redirect 重定向 IFrame 但不是整个页面。
谢谢, 毗湿奴
最佳答案
您可以添加 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));
关于c# - IFrame 中的 Response.REdirect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5012631/