Jump to content

background color blink


pankaj.ghadge

Recommended Posts

how to blink the background color .........e.g like in gmail when we do the chatting.................when the message arrived the chat window get blink.......when we click on that chat window that blink stops .............................so how to do this..............................please tell me....................

Link to comment
Share on other sites

<script type="text/javascript">function blinkit(){var intrvl=0;for(nTimes=0;nTimes<3;nTimes++){intrvl += 1000;setTimeout("document.bgColor='#0000FF';",intrvl);intrvl += 1000;setTimeout("document.bgColor='#FFFFFF';",intrvl);}}</script>

That should work. It's not css, and will need a bit of changing around for you.

Link to comment
Share on other sites

You can't do it with CSS, but there's a more efficient way to do this:

function blink(id) {  if(document.getElementById(id).style.backgroundColor != "red") {	document.getElementById(id).style.backgroundColor = "red";  } else {	document.getElementById(id).style.backgroundColor = "white";  }}

To call the blinking, do something like this:(If the object has the id "obj", like this: <div id="obj"></div>)

var B = setInterval(blink("obj"));

To stop it, do this:

clearInterval(B);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...