JS弹出新窗口,关闭新窗口时,刷新父窗口 JS代码实现刷新网页

这里有两个文件,主要要实现的是点父窗口里的弹出新窗口(详细请参考 JS控制窗口常用代码),将弹出新窗口,在新窗口里面有两个方法,一个是刷新本面,另一个是关闭本页,同时要刷新父窗口,其中f.htm为父页,z.htm为子页,代码如下(由于f.htm页内容不多,可能会刷新过快而没看到效果,你可以适当增加内容以便查看效果):
f.htm程序代码

<!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>  

z.htm 程序代码

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
  5. <title>子窗口</title>  
  6. <script language="javascript">  
  7. function closethewindow()   
  8. {   
  9. var url="f.htm";//要刷新的窗口   
  10. opener.document.location=url;   
  11. window.close();   
  12. }   
  13. </script>  
  14. </head>  
  15.   
  16. <body>  
  17. <span onclick="closethewindow();" style="cursor:hand;">关闭子窗口,刷新父窗口</span><br />  
  18. <span onclick="javascript:window.location.reload();" style="cursor:hand;">刷新此窗口</span>  
  19. </body>  
  20. </html>  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值