WebSys Fall 2006 : blink Javascript Source


<!-- Javascript: color changing text -->

<HTML>
<HEAD>
<TITLE>text that blinks (changes color)</TITLE>
</HEAD>
<BODY>

<H1>Sample Document</H1>

<P>Here is some stuff.
Here is some stuff. Here is some stuff. Here is some stuff.
Here is some stuff. Here is some stuff. Here is some stuff.
Here is some stuff. Here is some stuff. Here is some stuff.
Here is some stuff. Here is some stuff. Here is some stuff.
Here is some stuff. Here is some stuff. Here is some stuff.
</P>
<HR>

<P id="blinker" STYLE="color:red">
Here is some stuff. Here is some stuff. Here is some stuff.
Here is some stuff. Here is some stuff. Here is some stuff.
Here is some stuff. Here is some stuff. Here is some stuff.
Here is some stuff. Here is some stuff. Here is some stuff.
Here is some stuff. Here is some stuff. Here is some stuff.
</P>

<P>The above paragraph should blink</P>

</BODY>
<SCRIPT>

function flip() {
  // get the object corresponding to the paragraph with ID blinker
  b = document.getElementById("blinker");
  // change the color of the paragraph
  if (b.style.color=="red") {
    b.style.color="blue";
  } else {
    b.style.color="red";
  }
}
// schedule flip to run every 1/2 second
window.setInterval("flip()",500);
</script>