gpt4 book ai didi

javascript - 从代码隐藏打开的弹出窗口未关闭

转载 作者:行者123 更新时间:2023-12-02 20:14:11 25 4
gpt4 key购买 nike

我正在从代码后面打开一个弹出窗口(我在处理时将其用作等待图像),之后我在后台进行一些事件,当事件完成时,我将关闭该弹出窗口。问题是事件结束后弹出窗口没有关闭。我做错了什么,这是我的代码片段:-

    System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script language='javascript'>");
sb.Append("var win=");
sb.Append("window.open('WaitingImage.aspx', 'Wait',");
sb.Append("'width=800, height=600, menubar=no, resizable=no');window.focus();<");
sb.Append("/script>");

Type t = this.GetType();
if (!ClientScript.IsClientScriptBlockRegistered(t, "PopupScript"))
{
ClientScript.RegisterClientScriptBlock(t,"PopupScript", sb.ToString());
}
//pop up opened.. now do the processing :-
uploadFiles();
//now close the pop up after work is done:-

System.Text.StringBuilder sbs = new System.Text.StringBuilder();
sbs.Append("<script language='javascript'>");
sbs.Append("window.close()");
sbs.Append("/script>");
Type tr = this.GetType();
ClientScript.RegisterClientScriptBlock(tr, "PopupScript", sbs.ToString());

最佳答案

您将弹出窗口分配给 win 变量,但是当您关闭时,您调用 window.close...

尝试改变

 sbs.Append("window.close()");

 sbs.Append("win.close()");

关于javascript - 从代码隐藏打开的弹出窗口未关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6546053/

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