IE 11 Javascript对象不支持属性或方法'匹配'

时间:2014-04-06 12:53:43

标签: javascript

它是一个javascript倒计时它在Firefox& Chrome但无法使用IE 11.以下是代码

return this.each(function() {
  // Convert
  if(!(toDate instanceof Date)) {
    if(String(toDate).match(/^[0-9]*$/)) {
      toDate = new Date(toDate);
    } else if( toDate.match(/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})\s([0-9]{1,2})\:([0-9]{2})\:([0-9]{2})/) ||
        toDate.match(/([0-9]{2,4})\/([0-9]{1,2})\/([0-9]{1,2})\s([0-9]{1,2})\:([0-9]{2})\:([0-9]{2})/)
        ) {
      toDate = new Date(toDate);
    } else if(toDate.match(/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})/) || 
              toDate.match(/([0-9]{2,4})\/([0-9]{1,2})\/([0-9]{1,2})/)
              ) {
      toDate = new Date(toDate)
    } else {
      throw new Error("Doesn't seen to be a valid date object or string")
    }
  }

0 个答案:

没有答案