Hold on to your HAT!

Here comes a color surprise...


The Script

<html>
<head>
</head>
<body bgcolor="white">
<h2>Hold on to your HAT!</h2>
<SCRIPT type="text/javascript">
   for (i=1; i<=10001; i=i+1)
   {
   }
   document.bgColor="yellow"
</script>
Here Comes a Color Surprise!...
<SCRIPT type="text/javascript">
   for (i=1; i<=10001; i=i+1)
   {
   }
   document.bgColor="pink"
 </script>
</body>
</html>

     You could pretty much copy and paste the loop script twice and change out the count to ten grand. That was the easy part. The harder part was getting the event to occur. Look at the script. All we did was pull out any function after the loop and put the bgColor= command where the document.write command once was.

Close this window to return to JavaScript Primer #24