Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-28-2008, 06:54 PM   PM User | #1
cec energy
New to the CF scene

 
Join Date: Apr 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
cec energy is an unknown quantity at this point
Internet Explorer IE works from C: but not from internet

www.cecenter.org

I made a very simple ticker to approximate how much energy we have saved our clients. It works fine when I tested it just from the C drive. When I put it on the site it worked fine on FF but not IE. In fact, IE would load half the site and then say that it could not load the site, and then give an error page. If I hit "refresh" the site then shows up properly. Very strange?

It is particularly confusing because it will give an error every-other-time that I reload the page.

Here is my code:

Code:
<script type="text/javascript">
function doSomething()
{
	var allsecs = new Date()
	var time = allsecs.getTime()	
	var timeadjust = time - 1166832000000;
	moneysaved = 270000000 + .000475647 * timeadjust;
	moneysaved = moneysaved.toFixed(2);
	 
	var sRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');
	while(sRegExp.test(moneysaved)) 
	{
		moneysaved = moneysaved.replace(sRegExp, '$1,$2');
	} 
	
	document.getElementById("numchange").innerHTML = moneysaved;
}

setInterval ("doSomething()" , 1000 );
doSomething();

</script>
This is the doctype:

<!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" <?php language_attributes(); ?>>

Anyone have any ideas?
cec energy is offline   Reply With Quote
Old 04-28-2008, 07:02 PM   PM User | #2
mjlorbet
Regular Coder

 
mjlorbet's Avatar
 
Join Date: Jan 2008
Location: Milwaukee, WI
Posts: 724
Thanks: 8
Thanked 96 Times in 95 Posts
mjlorbet will become famous soon enough
change
Code:
 
setInterval ("doSomething()" , 1000 );
doSomething();setInterval ("doSomething()" , 1000 );
doSomething();
to
Code:
 
window.onload = function(){setInterval("doSomething()", 1000);};
and see if the results are different. if they are (and it works) then you've found a glitch in the ie js parser, basically the extended load time from the server is allowing the script to execute faster than the content is received, possibly causing ie to bug out & go to that message, the reason it would work on the refresh is that the page is already cached but it doesn't recognize this as it hasn't displayed it yet, the following refresh would give an error because it is trying to update content & would find the same problem. if that is the case (which i kind of doubt) then that would fix it for you. if it doesn't work, comment out that line, re-upload, clear your cache and visit the site again. if the error still occurs it likely has to do with the headers your php is returning and not the script, if it doesn't then ie just doesn't like the body of your function.
__________________
-Mike
"Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender
mjlorbet is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:54 AM.


Advertisement
Log in to turn off these ads.