PDA

View Full Version : Resolved Blink tag in javascript



bernie1227
05-16-2012, 09:35 AM
Hiya guys,
I was just wondering about the html blink tag. I know it doesnt work in all browsers, but I also know that you can acheive the same effect using javascript, so would you guys possibly be able to teach me some javascript that would do the equivalent of a blink tag for all browsers?
thanks,
bernie

keyboard
05-16-2012, 09:57 AM
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var blinkLength = 500;
function blink1(){
document.getElementById('div1').style.display = "block";
t1=setTimeout("blink2()",blinkLength);
}
function blink2(){
document.getElementById('div1').style.display = "none";
t2=setTimeout("blink1()",blinkLength);
}
</script>
</head>
<body onload="blink1()">
<div id="div1">Div Text</div>
</body>
</html>


Here's a simple example. When the page loads, the function blink1() is called. This then sets the divs style.display to block (visible).

It then waits 500 miliseconds before triggering blink2(). This then sets the divs style.display to none (invisible).

The variable var blinkLength = 500; is the number of miliseconds you want it to wait inbetween hides/unhides.

Hope this helps.
Keyboard1333

P.s. - Welcome to the forums bernie1227 ;)

keyboard
05-16-2012, 10:11 AM
If this thread is finished, please set it to resolved.
You can do this by editing the first post within the thread - Pressing go advanced - Then where it says no prefix, selecting resolved then save.