<html> <head> <script> function boom() { var f = document.getElementById("f"); var fd = f.contentDocument; fd.querySelectorAll("*"); fd.documentElement.innerHTML = "3"; document.body.removeChild(f); } </script> </head> <body onload="boom();"><iframe id="f" src="data:text/html,<html><head onfocus=2>"></iframe></body> </html>