...

View Full Version : JS & IE Fist fight



mainehat
10-11-2011, 05:37 AM
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>

:confused:

Kor
10-11-2011, 09:19 AM
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?

mainehat
10-11-2011, 03:05 PM
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

Ejean91
10-11-2011, 04:28 PM
It doesn't work for me either on IEX.

its saying

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.


document.getElementById('countbox').innerHTML=out;

make sure the last bit of that line is right, thats your entire line 46.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum