You can do something like this:
<div id="Foo">Blink</div>
Using a script:
$(document).ready(function() { var f = document.getElementById('Foo'); setInterval(function() { f.style.display = (f.style.display == 'none' ? '' : 'none'); }, 1000); });
Example: http://jsfiddle.net/7XRcJ/
If you are not using jQuery, you can try something like this:
window.addEventListener("load", function() { var f = document.getElementById('Foo'); setInterval(function() { f.style.display = (f.style.display == 'none' ? '' : 'none'); }, 1000); }, false);
Different browsers have different ways of binding event handlers, so I would highly recommend using some kind of cross-browser library for this kind of thing, if possible.
You can also try using the onload event in the body tag. Here is a complete example that I tested in FF and IE7:
function blink() { var f = document.getElementById('Foo'); setInterval(function() { f.style.display = (f.style.display == 'none' ? '' : 'none'); }, 1000); }
<html> <body onload="blink();"> <div id="Foo">Blink</div> </body> </html>
source share