IE8: Object Doesn't Support This Property or Method (Date function)

后端 未结 4 1390
忘了有多久
忘了有多久 2021-01-18 06:00

I\'m getting an error that only appears on the great IE8, it points to the following function, specifically the line: return (expDate.getTime() > Date.now());

相关标签:
4条回答
  • 2021-01-18 06:17

    Shim using the fact valueOf a Date is ms..

    if (!Date.now) Date.now = function () {return +new Date();};
    
    0 讨论(0)
  • 2021-01-18 06:17

    My psychic debugging skills tell me that you're using jQuery 2.0, which does not support IE8.

    You need to use 1.10.

    0 讨论(0)
  • 2021-01-18 06:29

    Looks like Date.now() isn't supported in IE8 (see the table at the bottom):

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now

    new Date() should get you a date object with the current date.

    0 讨论(0)
  • 2021-01-18 06:43

    IE 8 does not support Date.now. Implement it as :

    if(!Date.now) { Date.now = function(){ return new Date().getTime();};}
    
    0 讨论(0)
提交回复
热议问题