IE8:对象不支持此属性或方法(日期函数) [英] IE8: Object Doesn't Support This Property or Method (Date function)
问题描述
我收到的错误只出现在伟大的IE8上,它指向以下函数,特别是行: return(expDate.getTime()> Date.now());
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());
$.validator.addMethod("checkDocExpiry",function(value) {
var driverLicExp = ($('#drivers-license-expiration').val()) ? $('#drivers-license-expiration').val() : '';
if (driverLicExp != ''){
var expDate = new Date(driverLicExp);
return (expDate.getTime() > Date.now());
}else{
return (true);
}
}, "Your driver's license has expired.");
我不确定是什么原因造成这种情况,我对开发旧版浏览器相当新。这在FF,IE10,Chrome,Safari中运行良好。
I'm not sure what would cause this, I am fairly new to developing for older browsers. This runs fine in FF, IE10, Chrome, Safari.
任何帮助都将不胜感激。
Any help would be much appreciated.
谢谢
推荐答案
看起来 Date.now()
不支持IE8(见下表):
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()
应该为您提供当前日期的日期对象。
new Date()
should get you a date object with the current date.
这篇关于IE8:对象不支持此属性或方法(日期函数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!