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 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2010
    Posts
    55
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Question Problem IN FF and Chrome with countdown timer

    OK well one I have tried to contact the author of this application and he no longer writes or supports it and I know nothing about javascript... so here I am BEGGING FOR HELP!!! any body will to give this a go would love to try anything

    here is my problem the timer is self works fine but since new updates (RECENT) in Chrome and Firefox when you move away from the window it stop the count then when you come back to it the count starts again I dont want the count to stop any ideas would be great

    Code:
    window.onload=progressBarInit;
    
    
    
    // Timer Bar - Version 1.0
    
    // Author: Brian Gosselin of http://scriptasylum.com
    
    
    var loadedcolor='<?php echo $gSurfLoadColour; ?>' ;       // PROGRESS BAR COLOR
    
    var unloadedcolor='<?php echo $gSurfUnloadColour; ?>';     // COLOR OF UNLOADED AREA
    
    var bordercolor='<?php echo $gSurfLoadBoardColour; ?>';            // COLOR OF THE BORDER
    
    var barheight=15;                  // HEIGHT OF PROGRESS BAR IN PIXELS
    
    var barwidth=190;                  // WIDTH OF THE BAR IN PIXELS
    
    var waitTime=<?php echo $gSurfTimer - $members_time_deduct; ?>;                   // NUMBER OF SECONDS FOR PROGRESSBAR
    
    
    
    // THE FUNCTION BELOW CONTAINS THE ACTION(S) TAKEN ONCE BAR REACHES 100%.
    
    // IF NO ACTION IS DESIRED, TAKE EVERYTHING OUT FROM BETWEEN THE CURLY BRACES ({})
    
    // BUT LEAVE THE FUNCTION NAME AND CURLY BRACES IN PLACE.
    
    // PRESENTLY, IT IS SET TO DO NOTHING, BUT CAN BE CHANGED EASILY.
    
    // TO CAUSE A REDIRECT TO ANOTHER PAGE, INSERT THE FOLLOWING LINE:
    
    // window.location="http://redirect_page.html";
    
    // JUST CHANGE THE ACTUAL URL OF COURSE :)
    
    
    
    
    
    //*****************************************************//
    
    //**********  DO NOT EDIT BEYOND THIS POINT  **********//
    
    //*****************************************************//
    
    
    
    var ns4=(document.layers)?true:false;
    
    var ie4=(document.all)?true:false;
    
    var blocksize=(barwidth-2)/waitTime/10;
    
    var loaded=0;
    
    var PBouter;
    
    var PBdone;
    
    var PBbckgnd;
    
    var Pid=0;
    
    var txt='';
    
    if(ns4){
    
    txt+='<table border=0 cellpadding=0 cellspacing=0><tr><td>';
    
    txt+='<ilayer name="PBouter" visibility="hide" height="'+barheight+'" width="'+barwidth+'">';
    
    txt+='<layer width="'+barwidth+'" height="'+barheight+'" bgcolor="'+bordercolor+'" top="0" left="0"></layer>';
    
    txt+='<layer width="'+(barwidth-2)+'" height="'+(barheight-2)+'" bgcolor="'+unloadedcolor+'" top="1" left="1"></layer>';
    
    txt+='<layer name="PBdone" width="'+(barwidth-2)+'" height="'+(barheight-2)+'" bgcolor="'+loadedcolor+'" top="1" left="1"></layer>';
    
    txt+='</ilayer>';
    
    txt+='</td></tr></table>';
    
    }else{
    
    txt+='<div id="PBouter" style="position:relative; visibility:hidden; background-color:'+bordercolor+'; width:'+barwidth+'px; height:'+barheight+'px;">';
    
    txt+='<div style="position:absolute; top:1px; left:1px; width:'+(barwidth-2)+'px; height:'+(barheight-2)+'px; background-color:'+unloadedcolor+'; font-size:1px;"></div>';
    
    txt+='<div id="PBdone" style="position:absolute; top:1px; left:1px; width:0px; height:'+(barheight-2)+'px; background-color:'+loadedcolor+'; font-size:1px;"></div>';
    
    txt+='</div>';
    
    }
    
    
    
    function incrCount(){
    
    window.status="<?php echo $gSurfWStatusCD; ?>";
    
    loaded++;
    
    if(loaded<0)loaded=0;
    
    if(loaded>=waitTime*10){
    
    clearInterval(Pid);
    
    loaded=waitTime*10;
    
    setTimeout('hidebar()',100);
    
    }
    
    resizeEl(PBdone, 0, blocksize*loaded, barheight-2, 0);
    
    //alert((waitTime+1)-Math.ceil(loaded/10));
    
    tempcnt = (waitTime+1)-Math.ceil(loaded/10);
    
    document.getElementById('count').innerHTML=tempcnt;
    
    }
    
    
    
    function breaker_bar() {
    
    parent.np=1;
    
    parent.framesBreaking(false);
    
    return true;
    
    }
    
    
    
    function wrong() {
    
    	parent.wsftpaw.location.replace('../index.php?_w=wrong_button');
    
    }
    
    
    
    function submitform(id) {
    
    
    
    parent.np=1;
    
    parent.framesBreaking(false);
    
    document.surfform.cl.value=id;
    
    document.surfform.submit();
    
    }
    
    
    
    function hidebar(){
    
    document.getElementById('count').innerHTML=0;
    
    window.status='<?php echo $gSurfWStatusEnd; ?>';
    
    switchDiv('counter', false,0);
    
    switchDiv('buttons', true,0);
    
    
    
    }
    
    
    
    //THIS FUNCTION BY MIKE HALL OF BRAINJAR.COM
    
    function findlayer(name,doc){
    
    var i,layer;
    
    for(i=0;i<doc.layers.length;i++){
    
    layer=doc.layers[i];
    
    if(layer.name==name)return layer;
    
    if(layer.document.layers.length>0)
    
    if((layer=findlayer(name,layer.document))!=null)
    
    return layer;
    
    }
    
    return null;
    
    }
    
    
    
    function progressBarInit(){
    
    PBouter=(ns4)?findlayer('PBouter',document):(ie4)?document.all['PBouter']:document.getElementById('PBouter');
    
    PBdone=(ns4)?PBouter.document.layers['PBdone']:(ie4)?document.all['PBdone']:document.getElementById('PBdone');
    
    resizeEl(PBdone,0,0,barheight-2,0);
    
    if(ns4)PBouter.visibility="show";
    
    else PBouter.style.visibility="visible";
    
    Pid=setInterval('incrCount()',95);
    
    
    
    //Load the rest of the pages, loading sequence system

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,928
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    This is a very old script - NS4 and IE4 are long obsolete, and document.layers is no longer supported. The best suggestion is to get a more up-to-date script which is standards compliant in accordance with the W3C Document Object Model (DOM).

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New Coder
    Join Date
    Dec 2010
    Posts
    55
    Thanks
    8
    Thanked 0 Times in 0 Posts
    I am well aware that this is a old script it was written in 2005 I'm looking to updated it to work with current times any help in doing so would be great as for PHP and CFML I can handle javascript??? no clue

    but this in a widely used application and up till about 3 months ago worked great now just the timer stops when you navigate away from the page and then starts again when you come back I want it to keep counting down if you are on the page or not

    Quote Originally Posted by Philip M View Post
    This is a very old script - NS4 and IE4 are long obsolete, and document.layers is no longer supported. The best suggestion is to get a more up-to-date script which is standards compliant in accordance with the W3C Document Object Model (DOM).

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.


  •  

    Posting Permissions

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