Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Image | Q1327 [ previous next ]

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>

©2018 Martin Webb