Hit Counter object problem in IE.

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Hit Counter object problem in IE.

Post by JellyFish »

Hi, I'm creating this object for a Ajax hit counter. The idea is that the object holds all the modules for the hit counter and that the modules interact with each other. My hit counter has very few elements involved:

Code: Select all

<div id="hitCounter"><span id="count">[hit count]</span>Views</div>
. But the real problem I'm having is in the object I created:

Code: Select all

hitCounter = {
	
	ajaxInterval: setTimeout('hitCounter.getCount()', 2000),
	gradualInterval: undefined,
	
	gradualAdd: function (addend) {
		if (addend > 0)
		{
			var sum = parseInt($("#hitCounter #count").text()) + addend;
			
			hitCounter.gradualInterval = setInterval(function () {
				hitCounter.gradualIntervalFunction(addend, sum);
			}, 2000 / addend);
		}
		else
		{
			hitCounter.ajaxInterval = setTimeout('hitCounter.getCount()', 2000);
		}
	},
	gradualIntervalFunction: function (addend, sum) {
		var currentCount = parseInt($("#hitCounter #count").text());
		if (currentCount == sum)
		{
			clearInterval(hitCounter.gradualInterval);
			hitCounter.ajaxInterval = setTimeout('hitCounter.getCount()', 1000);
		}
		else
		{
			$("#hitCounter #count").text(currentCount+1);
		}
	},
	getCount: function() {
		$.get("hit-counter.php", {update: ""}, function (data) {
			var addend = data - $("#hitCounter #count").text();
			hitCounter.gradualAdd(addend);
		});
	}
};
All works FANTASTIC in Firefox! But not in IE... :(

I'm thinking it might be the way the modules are interacting with one another, but I'm not certain. I need a Firebug for IE, or at least somewhat of a firebug, so any recommendations for a program?

Thanks for taking the time to read this. :)
Post Reply