我正在从后面的代码打开一个弹出窗口(我在处理时使用它作为等待图像)之后我在后台做一些活动,当活动完成时我正在关闭弹出窗口。问题是活动结束后pop没有关闭。我做错了什么,这是我的代码片段: -
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());
答案 0 :(得分:2)
您将弹出窗口分配给win变量,但是当您关闭时,请调用window.close ...
尝试更改
sbs.Append("window.close()");
到
sbs.Append("win.close()");