RegisterStartupScript的用法

 

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'之后。因为先清掉句柄的话,就不能 
  控制父窗口的刷新了。

posted @ 2007-08-31 11:27  wj-conquer  阅读(1083)  评论(0编辑  收藏  举报