打开新窗体,新窗体关闭,刷新父窗体。

父窗体:

<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >    
< html  xmlns ="http://www.w3.org/1999/xhtml" >    
< head >    
< meta  http-equiv ="Content-Type"  content ="text/html; charset=gb2312"   />    
< title > 父窗口 </ title >    
</ head >    
   
< body >    
< span  onclick ="window.open('z.htm')"  style ="cursor:hand;" > 打开子窗口 </ span >    
</ body >    
</ html >    

子窗体:

<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >    
< html  xmlns ="http://www.w3.org/1999/xhtml" >    
< head >    
< meta  http-equiv ="Content-Type"  content ="text/html; charset=gb2312"   />    
< title > 子窗口 </ title >    
< script  language ="javascript" > ...   
function closethewindow()    
...
{    
var url="f.htm";//要刷新的窗口    
opener.document.location=url;    
window.close();    
}
    
</ script >    
</ head >    
   
< body >    
< span  onclick ="closethewindow();"  style ="cursor:hand;" > 关闭子窗口,刷新父窗口 </ span >< br  />    
< span  onclick ="javascript:window.location.reload();"  style ="cursor:hand;" > 刷新此窗口 </ span >    
</ body >    
</ html >    

asp.net

父窗口弹出子窗口的 button处理事件:

// 父窗口弹出子窗口的 button处理事件:
private   void  Button1_Click( object  sender, System.EventArgs e)
  
{
   Response.Write(
"<script language=javascript>window.open('WebForm1.aspx','', 'alwaysRaised=1,dependent=1,resizable=0,scrollbars,width=450,height=550');</script>");
  }

// 父窗口html代码添加如下javascript代码
< script language = " javascript " >  
function refresh() 

this.location = this.location; 
}
 
</ script >
// 子窗口关闭窗口的 button处理事件:
private   void  Button1_Click( object  sender, System.EventArgs e) 

StringBuilder scriptString 
= new StringBuilder(); 
scriptString.Append(
"<script language = javascript>"); 
scriptString.Append(
"window.opener.refresh();"); 

scriptString.Append( 
" window.focus();" ); 
scriptString.Append( 
" window.opener=null;" ); 
scriptString.Append( 
" window.close(); " ); 

scriptString.Append(
"</"+"script>"); 
Response.Write(scriptString.ToString()); 

// Response.Write("<script language=javascript>window.close()</script>"); 
}

 

其它可以参考的网页:

http://dev.csdn.net/article/48935.shtm

http://blog.csdn.net/blackhero/archive/2005/06/23/401000.aspx

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值