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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blinking text for x amount of time?

Status
Not open for further replies.

axsom1

Technical User
Feb 27, 2001
67
US
Hi all, javascript newb here. I was wondering how I can get some text to come up and blink when a page is first loaded. Now, I want this text to only blink for say 15 seconds then go away.

How is this accomplished??

Thanks,
John
 
here's one way which shouldn't affect accessibility:
Code:
<html>
	<head>
		<title>blink</title>

		<script type=&quot;text/javascript&quot;>
			function blink(id) {
				var seconds = 15;
				self.x = self.x ? self.x : 0;
				el = document.getElementById(id);
				
				if (self.x++ < (seconds * 2)) {
					el.style.visibility = 
						el.style.visibility == &quot;visible&quot; ?
						&quot;hidden&quot; : &quot;visible&quot;;
					setTimeout(&quot;blink('&quot; + id + &quot;');&quot;, 500);
				}
				else el.style.visibility = &quot;hidden&quot;;
			}
		</script>
	</head>

	<body onload=&quot;blink('msg');&quot;>
		<div>static text</div>
		<div id=&quot;msg&quot;>i blink for 15 seconds!</div>
		<div>static text</div>
	</body>
</html>

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Thanks Jeff, that works perfect for me.

Damn, I'm tickled pink about that...

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top