FF keeps spinning after document.write ()
<html> <head> <script type="text/javascript" > function fn() { document.write("Hello there!!!"); } </script> </head> <body> <button onclick="fn()">click</button> </body> </html> After pressing the button, FF continues to rotate (11.0), and if I directly call fn () without connecting it to the button, it works fine. Can anyone think of this?
You need to call document.close() . document.write calls document.open if the document has not been opened. Until the document is closed again using document.close , the browser will indicate that the page can be resized.
function fn() { // implicit call to `document.open();` before document.write document.write("Hello there!!!"); document.close(); }