<script> var x = 0; function write_stuff() { x++; document.open(); document.write("<p>" + x + "</p>"); } </script> <body onload="alert('child'); write_stuff()"> </body>