【问题标题】:Redirect to another page after window.open在 window.open 之后重定向到另一个页面
【发布时间】:2018-08-05 04:40:23
【问题描述】:

我希望单击按钮后会生成一个文件并在新窗口中打开,并且用户从父页面重定向到另一个页面。

     string script = "<script>window.open('" FilePath "')</script>";
                    Page page = HttpContext.Current.CurrentHandler as Page;
                    if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("pdf"))
                    {
                        page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "pdf", script);

                    }
Response.Redirect("Login.aspx");

我写上面的代码来打开车库文件新窗口然后重定向。

但是如果有重定向代码,window.open 就不能正常工作。 没有重定向 window.open 工作正常。

谁能告诉我怎么回事?

谢谢

【问题讨论】:

    标签: asp.net asp.net-webpages


    【解决方案1】:

    您必须在客户端加载 html 内容后进行重定向。因此,在这种情况下,您必须在客户端使用 javascript 进行重定向。

    string script = "<script>window.open('" FilePath "'); window.location.href = '/Login.aspx';</script>";
    

    【讨论】:

      猜你喜欢
      • 2017-06-08
      • 2021-01-11
      • 2017-03-04
      • 1970-01-01
      • 1970-01-01
      • 2011-06-02
      • 1970-01-01
      相关资源
      最近更新 更多