Techblog

Technical Blog about all things computer

  • Sep 26

     

     

    If you want a text to blink below is the function.

    <SCRIPT type=text/javascript>
     

     

    function blink(idname) {
    var speed = 300;

     

          s = document.getElementById(idname);
    if (typeof(s) !== ‘undefined’)  {

    s.style.visibility=(s.style.visibility==’visible’)?’hidden’:’visible’;

    setTimeout(‘blink(\”+ idname +’\’)’,speed); 

    }

    }

     

    </SCRIPT>

    <body onload=”blink(‘blink_this_text’)”>
    <p id=blink_this_text> Blinking Text </p>

    </body>

     

    Summary: Upon loading the page, the onload function will call the blink function passing along the id of the paragraph, blink_this_text.  The blink speed is set to 300 milli  seconds interval. It then gets the blink_this_text object using the getElemenbById command. If it exists. Visibility is set to hidden if it is visible otherwise it’s invisible. The blinking text function is then called again using the setTimeout function.

    Hope this was helpful and happy coding!