Results 1 to 3 of 3

Thread: Blink tag in javascript

  1. #1
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    46
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default Blink tag in javascript

    Hiya guys,
    I was just wondering about the html blink tag. I know it doesnt work in all browsers, but I also know that you can acheive the same effect using javascript, so would you guys possibly be able to teach me some javascript that would do the equivalent of a blink tag for all browsers?
    thanks,
    bernie
    Last edited by bernie1227; 05-16-2012 at 10:13 AM.

  2. #2
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <script type="text/javascript">
    var blinkLength = 500;
    function blink1(){
    	document.getElementById('div1').style.display = "block";
    	t1=setTimeout("blink2()",blinkLength);
    }
    function blink2(){
    	document.getElementById('div1').style.display = "none";
    	t2=setTimeout("blink1()",blinkLength);
    }
    </script>
    </head>
    <body onload="blink1()">
    <div id="div1">Div Text</div>
    </body>
    </html>
    Here's a simple example. When the page loads, the function blink1() is called. This then sets the divs style.display to block (visible).

    It then waits 500 miliseconds before triggering blink2(). This then sets the divs style.display to none (invisible).

    The variable var blinkLength = 500; is the number of miliseconds you want it to wait inbetween hides/unhides.

    Hope this helps.
    Keyboard1333

    P.s. - Welcome to the forums bernie1227

  3. The Following User Says Thank You to keyboard For This Useful Post:

    bernie1227 (05-16-2012)

  4. #3
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    If this thread is finished, please set it to resolved.
    You can do this by editing the first post within the thread - Pressing go advanced - Then where it says no prefix, selecting resolved then save.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •