The following code waits 2 seconds then prints some hello worlds.
<!DOCTYPE html>
<html>
<body onload="myTimedFunction()">
<script>
function myTimedFunction() {
setTimeout(function() { document.write("hello world");document.write(" hello world2");runMe();}, 2000);
}
function runMe(){document.write(" hello world3");}
</script>
<br>
<p>This text will disappear when the script runs</p>
</body>
</html>
like it says in the p tag the text disapears after the script has run. Furthermore, the webpage shows "Connecting..." with a loading symbol next to it when the script runs; this goes away when I hit escape. Why does the text disappear? Why is the javascript not stopping until I hit escape, missing semicolon? I am using firefox, in chrome the "Connecting..." never comes up, but the text still vanishes. Thank you for reading.