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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Location
    USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JS & IE Fist fight

    I can't get my JS counter to display in IE. Any suggestions?

    <script type="text/javascript">

    dateFuture = new Date(2011,9,22,22,46,40);

    function GetCount(){

    dateNow=new Date();
    amount=dateFuture.getTime() - dateNow.getTime();
    delete dateNow;

    if(amount < 0){
    document.getElementById('countbox').innerHTML="Now!";
    }

    else{
    days=0;hours=0;mins=0;secs=0;out="";

    amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs

    days=Math.floor(amount/86400);//days
    amount=amount%86400;

    hours=Math.floor(amount/3600);//hours
    amount=amount%3600;

    mins=Math.floor(amount/60);//minutes
    amount=amount%60;

    secs=Math.floor(amount);//seconds

    if(days != 0){out += days +" day"+((days!=1)?"s":"")+", ";}
    if(days != 0 || hours != 0){out += hours +" hour"+((hours!=1)?"s":"")+", ";}
    if(days != 0 || hours != 0 || mins != 0){out += mins +" minute"+((mins!=1)?"s":"")+", ";}
    out += secs +" seconds";
    document.getElementById('countbox').innerHTML=out;

    setTimeout("GetCount()", 1000);
    }
    }

    window.onload=function(){GetCount();}
    </script>


  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Quote Originally Posted by mainehat View Post
    I can't get my JS counter to display in IE. Any suggestions?
    It works for me in all the IE versions I have: IE7, IE8, IE9 / Win7. So?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Oct 2011
    Location
    USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Just blank

    I've tested it on several machines and had a few friends look too and none of us can see anything where the ticker is supposed to be. It's making me crazy, I can't figure out why it isn't showing.

    Here's how I have the page built:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>The Page</title>
    <link href="styles.css" rel="stylesheet" type="text/css" media="screen" />
    </script>
    </head>

    <script type="text/javascript">
    <!-- //

    dateFuture = new Date(2011,9,22,22,46,40);

    function GetCount(){

    dateNow=new Date();
    amount=dateFuture.getTime() - dateNow.getTime();
    delete dateNow;

    // time is already past
    if(amount < 0){
    document.getElementById('countbox').innerHTML="Now!";
    }
    // date is still good
    else{
    days=0;hours=0;mins=0;secs=0;out="";

    amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs

    days=Math.floor(amount/86400);//days
    amount=amount%86400;

    hours=Math.floor(amount/3600);//hours
    amount=amount%3600;

    mins=Math.floor(amount/60);//minutes
    amount=amount%60;

    secs=Math.floor(amount);//seconds

    if(days != 0){out += days +" day"+((days!=1)?"s":"")+", ";}
    if(days != 0 || hours != 0){out += hours +" hour"+((hours!=1)?"s":"")+", ";}
    if(days != 0 || hours != 0 || mins != 0){out += mins +" minute"+((mins!=1)?"s":"")+", ";}
    out += secs +" seconds";
    document.getElementById('countbox').innerHTML=out;

    setTimeout("GetCount()", 1000);
    }
    }

    window.onload=function(){GetCount();}
    </script>
    <body>




    Then I call it using

    <div id="countbox"></div>


    I can see it on Mac in everything, and on Windows in everything but IE

  • #4
    New Coder
    Join Date
    Sep 2011
    Location
    Braintree, Massachusetts
    Posts
    48
    Thanks
    1
    Thanked 0 Times in 0 Posts
    It doesn't work for me either on IEX.

    its saying
    Code:
    document.getElementById().
    is null or not an object at line 46 character 1 with a code of 0.

    same issue on yours? if so, try to get 'countbox' to call correctly.

    Code:
    document.getElementById('countbox').innerHTML=out;
    make sure the last bit of that line is right, thats your entire line 46.
    Last edited by Ejean91; 10-11-2011 at 05:30 PM.


  •  

    Posting Permissions

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