【问题标题】:How to redirect the page to the parent frame?如何将页面重定向到父框架?
【发布时间】:2013-12-20 10:15:38
【问题描述】:

我正在尝试将页面重定向到父框架。通过使用以下代码。

   ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('myPage.aspx','_Parent')", true);

但此代码在 Google chrome 和 IE 中不起作用。但它在 Mozilla 中可以正常工作。 谁能告诉我如何使此代码独立于浏览器?

【问题讨论】:

    标签: c# javascript internet-explorer google-chrome


    【解决方案1】:

    使用以下命令代替 window.open:

    window.location = "[url]";

    如果您希望父窗口显示指定的 URL,请使用:

    window.parent.location = "[url"];

    【讨论】:

    • 你能告诉我在c#中如何使用它吗?我想用 c# 编写这段代码。
    • 我认为你在第二个代码示例中有一个带引号的错字。
    【解决方案2】:

    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "a", "parent.window.location.assign('Test.aspx')", true);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-19
      • 2010-12-04
      • 1970-01-01
      • 1970-01-01
      • 2021-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多