01.<SCRIPT type=text/javascript>
02.var dg = frameElement.dg, cwin;
03.function closeWindow()
04.{
05. dg.cancel();
06.}
07.</SCRIPT>
查看代码 复制到剪贴板
01.protected void b4_Click(object sender, EventArgs e)
02. {
03. try
04. {
05. //两种方法是有区别的 用之前考虑情况
06. //方法1:
07. //注册到尾部 ,HTML元素已加载完毕
08. this.Page.ClientScript.RegisterStartupScript(this.GetType(), "close1", "closeWindow()", true);
09. //方法2:
10. //注册到头部 ,此时HTML还未加载!
11. //js会报 缺少对象
12. this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "close12", "closeWindow()", true);
13. }
14. catch
15. {
16.
17. }
18. }