Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1327 How do I make an image blink on and off a specified number of times when a certain function executes?

irt.org | Knowledge Base | JavaScript | Image | Q1327 [ previous next ]

Q1327 How do I make an image blink on and off a specified number of times when a certain function executes?

Try:

<script language="JavaScript"><!--
times = 0;
onOrOff= 'on';
rate = 500; // blinks every half second

function blinkImage() {
   if (onOrOff == 'on') onOrOff = 'off';
   document.images['myImage'].src = 'myimage' + onOrOff + '.gif';
   times--;
   if (times <= 0) return;
   setTimeout('blinkImage()',rate);
}

function someFunction() {
   times = 3;
   setTimeout('blinkImage()',rate);
}
//--></script>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.