Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make a picture blink

Status
Not open for further replies.

mdr227

Programmer
Nov 17, 2000
114
US
Can anyone tell me the code to make a picture blink?
 
One method is to hide and show the picture using a timer this way :
Code:
<html>
<head>
<title>Blinking image</title>
<Script language=&quot;javascript&quot;>
  var o_interval
  var delay=500 // define blink delay to 1/2 second

  function makeBlink() {
    o_interval = window.setInterval(&quot;ShowHide()&quot;, delay);
  }
  function stopBlink() {
    window.clearInterval(o_interval);
  }

  function ShowHide() {
    var o_img = document.getElementById(&quot;blinkImg&quot;);
    if (o_img.style.visibility==&quot;hidden&quot;)
      o_img.style.visibility=&quot;visible&quot;
    else
      o_img.style.visibility=&quot;hidden&quot;
  }
</Script>	
</head>
<body>
  <img id=&quot;blinkImg&quot; src=&quot;.\1.gif&quot; style=&quot;visibility : visible&quot;>
  <input type=&quot;button&quot; value=&quot;make blink&quot; onclick=&quot;makeBlink();&quot;>
  <input type=&quot;button&quot; value=&quot;stop blink&quot; onclick=&quot;stopBlink();&quot;>
</body>
</html>

I tested this code under ie6, it worked fine. Change delay variable value to make it blink slower or faster. Water is not bad as long as it stays out human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top