gpt4 book ai didi

asp.net - iFrame 中的 Response.Redirect(),重定向父窗口

转载 作者:行者123 更新时间:2023-12-04 13:09:47 25 4
gpt4 key购买 nike

我知道这是不可能的,但是想要做的最佳选择是什么 Response.Redirect从 iFrame 重定向父页面?

最佳答案

您不能使用 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'。

关于asp.net - iFrame 中的 Response.Redirect(),重定向父窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7307285/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com