9 Replies - 9726 Views - Last Post: 28 February 2011 - 12:36 PM

#1 josh06  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 139
  • Joined: 27-October 06

Object doesn't support this property or method

Posted 28 February 2011 - 08:38 AM

Hi all!

I have countdowns on a website I am creating, which I was helped with by a member on the forum. It works out the timestamp given to it into hours and minutes etc and counts down to then. It's working brilliantly in all browsers, except IE.

I've debugged the code in the Developer Toolkit on IE 8, tried it with all standard modes on it and it is just not working. Apparently on line 53 it says Object doesn't support this property or method.

The code for this is:

 function updateExpires(target)
	{
	    var elem = $(target);
            
	    var stamp = parseInt(elem.attr('expires'));
	    var now = Date.now() / 1000;
	
	    // Make sure the expiration data is in the future.
	    if (stamp > now)
	    {

		var remaining = stamp - now;
		var hours = Math.floor(remaining / 3600);
		var minutes = Math.floor((remaining - (hours * 3600)) / 60);
		var seconds = Math.floor(remaining - (hours * 3600) - (minutes * 60));
	

		hours = hours < 10 ? "0" + hours : hours;
		minutes = minutes < 10 ? "0" + minutes : minutes;
		seconds = seconds < 10 ? "0" + seconds : seconds;
	

		elem.html(hours + " hours, " + minutes + " minutes and " + seconds + " seconds");
	    }
	    else
	    {
		// This one is expired.
		elem.html("Expired!");
		elem.css('color', 'red');
		window.clearInterval(this.intRef);
	    }
	}



It is having a problem with the variable 'now'. Which is on the first few lines of code there.
Can anyone tell me why on earth this variable is not 'supported' under IE?

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Object doesn't support this property or method

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4188
  • View blog
  • Posts: 13,236
  • Joined: 08-June 10

Re: Object doesn't support this property or method

Posted 28 February 2011 - 08:44 AM

the now() method is simply not implemented in IE. try getTime()
Was This Post Helpful? 0
  • +
  • -

#3 josh06  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 139
  • Joined: 27-October 06

Re: Object doesn't support this property or method

Posted 28 February 2011 - 08:54 AM

Ok I'll try that.

Thanks
Was This Post Helpful? 0
  • +
  • -

#4 josh06  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 139
  • Joined: 27-October 06

Re: Object doesn't support this property or method

Posted 28 February 2011 - 09:26 AM

This is odd! I still can't get it to work.
I'm going to try echoing out time stamp via php and getting it in javascript to use that instead.

Can't see why it's not working though
Was This Post Helpful? 0
  • +
  • -

#5 josh06  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 139
  • Joined: 27-October 06

Re: Object doesn't support this property or method

Posted 28 February 2011 - 09:33 AM

Nope, of course that didn't work.
Because the time needs updating every second - which is what is happening with my code in all browsers except IE. It's even telling me that the Date object isn't supported..
Was This Post Helpful? 0
  • +
  • -

#6 josh06  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 139
  • Joined: 27-October 06

Re: Object doesn't support this property or method

Posted 28 February 2011 - 09:53 AM

I'm sorry that I keep posting but now I've got this.

I use this code
            
var my_date = new Date();
var now = my_date.getTime() / 1000;



It runs in the other browsers, but doesn't run in IE. But, it shows no errors in the debug..
Anyone got a clue?

------------------------------------------
Could it be something to do with
    $(".story-expires").each(function(){
	window.setInterval(updateExpires,1000,this);
    })



? That's all I can see that would stop it working - it's not updating like it should?

This post has been edited by josh06: 28 February 2011 - 10:00 AM

Was This Post Helpful? 0
  • +
  • -

#7 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4188
  • View blog
  • Posts: 13,236
  • Joined: 08-June 10

Re: Object doesn't support this property or method

Posted 28 February 2011 - 10:18 AM

Iím not sure IE supports additional parameters in the setInterval() function Ö
Was This Post Helpful? 1
  • +
  • -

#8 josh06  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 139
  • Joined: 27-October 06

Re: Object doesn't support this property or method

Posted 28 February 2011 - 10:22 AM

I know now, I just saw on the MSDN site..
How else could I pass the variable to the function?..
Was This Post Helpful? 0
  • +
  • -

#9 josh06  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 139
  • Joined: 27-October 06

Re: Object doesn't support this property or method

Posted 28 February 2011 - 10:58 AM

Ok,

so now I've realised why it's not updating in IE. You can't pass arguments the way I was trying.
I've tried passing the argument like so:
        var targeted = $(this);
        window.setInterval("updateExpires('targeted')",1000);



As the function requires a target to work out its expiry time, however
I can't seem to pass the "this" variable over setInterval.
I'm really really stuck here :/
Was This Post Helpful? 0
  • +
  • -

#10 josh06  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 139
  • Joined: 27-October 06

Re: Object doesn't support this property or method

Posted 28 February 2011 - 12:36 PM

Sorted. Just found a script online that does what I need - a bit of editing and its perfect.
http://andrewu.co.uk/clj/countdown/

Can anyone mark as solved?
Thanks for your help Dormilich
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1