...

View Full Version : Blinking text in javascript



mailkev14
08-01-2011, 08:05 AM
I have written a small code in Javascript which does the work of blinking all the content inside any tag with the name 'blink'

here is the code

<html>
<body>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>

<script type="text/javascript">
function blinkText()
{
var x=document.getElementsByName('blink');
for(i=0;i<x.length;i++)
{
if(x[i].style.visibility=='visible')
x[i].style.visibility='hidden';
else
x[i].style.visibility='visible';
}
}
setTimeout('blinkText()',500);
</script>
</body>
</html>



I use a Ubuntu system and work on Mozilla 3.6.18
This hides the text successfully but does not display it again
What can be wrong here?

Can anyone please help me

Philip M
08-01-2011, 08:22 AM
http://www.codingforums.com/showthread.php?t=80299

You should note the warning that blink is poor accessibility since it could conceivably trigger a seizure in someone who has photo-sensitive epilepsy - I would advise you not do anything, CSS based or otherwise, that causes text to blink. You could easily find that you have attracted a swarm of expensive lawyers. There is a US standard somewhere about this. (Section 508 Amendment to the Rehabilitation Act of 1973)

This is all about courage, whether you've got the balls to actually smell what is going on in business. - Alan Sugar BBC1

mailkev14
08-01-2011, 08:30 AM
I have written a small code in Javascript which does the work of blinking all the content inside any tag with the name 'blink'

here is the code

<html>
<body>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>
<p name="blink" style="visibility: visible;">This text blinks using Javascript</p>

<script type="text/javascript">
function blinkText()
{
var x=document.getElementsByName('blink');
for(i=0;i<x.length;i++)
{
if(x[i].style.visibility=='visible')
x[i].style.visibility='hidden';
else
x[i].style.visibility='visible';
}
}
setTimeout('blinkText()',500);
</script>
</body>
</html>



I use a Ubuntu system and work on Mozilla 3.6.18
This hides the text successfully but does not display it again
What can be wrong here?

Can anyone please help me

I got the answer to my quertion itself
I forgot to add the setTimeout method within the function itself so that it can recursively call itself

mailkev14
08-01-2011, 08:32 AM
http://www.codingforums.com/showthread.php?t=80299

You should note the warning that blink is poor accessibility since it could conceivably trigger a seizure in someone who has photo-sensitive epilepsy - I would advise you not do anything, CSS based or otherwise, that causes text to blink. You could easily find that you have attracted a swarm of expensive lawyers. There is a US standard somewhere about this. (Section 508 Amendment to the Rehabilitation Act of 1973)

This is all about courage, whether you've got the balls to actually smell what is going on in business. - Alan Sugar BBC1

Thanks for letting me know



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum