导航栏: 首页 评论列表

window1中点击一个link打开window2,在window2中点击一个button,跳转回window1并在window1上alert(“done”),点击确定alert,window2 close

默认分类 2011-09-04 19:16:46

a.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.   
  4. <head>  
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  6. <title>Untitled 1</title>  
  7. <script type="text/javascript">  
  8. <!--  
  9. var a;  
  10. function popup(){  
  11.     a = window.open('b.htm');  
  12. }  
  13. function showMsg(){  
  14.     alert(123);  
  15.     a.close();  
  16. }  
  17. //-->  
  18. </script>  
  19. </head>  
  20.   
  21. <body>  
  22. <a href="#nogo" onclick="popup()">open</a>  
  23. </body>  
  24.   
  25. </html>  

b.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.   
  4. <head>  
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  6. <title>Untitled 1</title>  
  7. <script type="text/javascript">  
  8. <!--  
  9. function go(){  
  10. window.opener.focus();  
  11. window.opener.showMsg();  
  12.   
  13. }  
  14. //-->  
  15. </script>  
  16. </head>  
  17.   
  18. <body>  
  19. <button onclick="go()">back</button>  
  20. </body>  
  21.   
  22. </html>  


>> 留言评论