大家好,又见面了,我是你们的朋友全栈君。
![RegisterStartupScript的用法[通俗易懂]](https://javaforall.net/wp-content/uploads/2020/11/2020110817443450.jpg)
Page.RegisterStartupScript(
“
CloseAndRefresh
“
,
“
<script language=’javascript’>window.close);window.opener=null;window.parent.location.href=’mydocument.aspx’;</script>
“
)
1、Page.RegisterStartupScript(1,2)
参数1是这段脚本的名称,有点象控件的name;参数2是脚本组成的字符串。
2、window.close()
关闭当前窗口。
3、window.parent.location.href=’mydocument.aspx’
将父窗口的连接地址重写,也就是刷新一下。
4、window.opener=null;
将父窗口的句柄清掉。
注:再次重申,window.opener=null;要放在window.parent.location.href=’mydocument.aspx’之后。因为先清掉句柄的话,就不能
控制父窗口的刷新了。
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/154748.html原文链接:https://javaforall.net