1 <html> 2 <head> 3 <title>Remove Frame on Unload</title> 4 <script> 5 function openWindow() { 6 var w = window.open("title1.html"); 7 return true; 8 } 9 10 window.addEventListener('unload', function() { 11 var f = document.getElementById("f"); 12 document.body.removeChild(f); 13 }, false); 14 </script> 15 </head> 16 <body> 17 <button onclick="openWindow()">Open Window</button> 18 <p>Navigate to another page to cause frame to be removed.</p> 19 <iframe id="f" src="about:blank"></iframe> 20 </body> 21 </html> 22