Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Blinking test

  1. #1
    New Coder
    Join Date
    Dec 2003
    Location
    australia
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Blinking test

    Hello,

    I've found a script on the Net that allows me to run blinking text. However I would like to stop the blinking after 5 seconds. Can anyone offer the code that will achieve this (in this script) and where to place it. The script is as follows,

    <body>
    <script> var d,ctr=0; function init(){ if(document.all){d=document.all['div1'].style;} else if(document.layers){d=document.layers['div1'];} blink(); } function blink() { ctr++; if(ctr==0){d.visibility="hidden";} else{d.visibility="visible";} if(ctr>0)ctr-=2; setTimeout("blink()",1000); } </script>
    <body onLoad="init()">
    <div id="div1" style="position:relative; width:200; ">Searching</div>
    </body>

    Cheers

    Abbas

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:
    Code:
    <body>
    <script type="text/javascript">
    <!--//
    var d,ctr=0;
    function init(){
    if(document.all){
    d=document.all['div1'].style;
    }
    else if(document.layers){
    d=document.layers['div1'];
    }
    blink();
    }
    function blink() {
    ctr++;
    if(ctr==0){
    d.visibility="visible";
    }
    else{
    d.visibility="hidden";
    }
    if(ctr>0)ctr-=2;
    timer = setTimeout("blink()",1000);
    setTimeout("stop()",10000);
    }
    
    function stop(){
    clearTimeout(timer);
    ctr=0;
    }
    //-->
    </script>
    <body onLoad="init()">
    <div id="div1" style="position:relative;
    width:200;
    ">Searching</div>
    </body>

  • #3
    New Coder
    Join Date
    Dec 2003
    Location
    australia
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Willy,

    Thanks for the fast reply. Appreciated. Works a treat.

    Abbas

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nb - the Web Content Accessibility Guidelines specifically say - do not cause text to blink. http://www.w3.org/TR/WAI-WEBCONTENT/#tech-avoid-flicker

    Blinking text may trigger a seizure in someone who has photosensitive epilepsy; it's unlikely, but possible.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #5
    New Coder
    Join Date
    Dec 2003
    Location
    australia
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the advise,

    There are only 5 blinks and then the (8pt) word disappears.


    Abbas


  •  

    Posting Permissions

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