在NET中关闭弹出窗口并刷新父页面


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

?

?案例1:父页面A.aspx弹出窗口B.aspx;关闭B.aspx页面刷新A.aspx;在B.aspx的点击关闭按钮时执行下列代码:

?? 1. string popupScript = “<script language=’javascript’>” + “alert(‘Submit successfully!’);window.opener.document.forms[0].submit();window.opener =null;window.close();” + “</script>”;? //可看出aspx都有一个from,所谓任何动态如button click都是form submit的结果。若无form,则页面会报错。
?? 2.???????????? Page.ClientScript.RegisterStartupScript(this.GetType(), “PopupScript1”, popupScript);

案例1:父页面A.aspx弹出窗口B.aspx;在B.aspx页面弹出C.aspx;关闭C.aspx并关闭B.aspx并刷新父页面A.aspx;在C.aspx的点击关闭按钮时执行下列代码:

?? 1. string popupScript = “<script language=’javascript’>” + “window.opener.opener.document.forms[0].submit();window.opener.opener = null;window.opener.close();window.opener=null;window.close();” + “</script>”;
?? 2.???????? Page.ClientScript.RegisterStartupScript(this.GetType(), “PopupScript1”, popupScript);

说明:

1.alert(‘Submit successfully!’):弹出窗口显示信息’Submit successfully!’;

2.window.opener.opener.document.forms[0].submit():重新提交父页面的信息;

3.window.opener.opener = null;window.opener.close();关闭上级窗口不弹出提示框;

4.window.opener=null;window.close();关闭本窗口不弹出提示