IE8 为 Date.now() 显示“对象不支持此属性或方法”
IE8 says 'Object doesn't support this property or method' for Date.now()
抱歉粘贴了这么多代码,这对于突出问题可能很有用:
Client.prototype.connect = function (login, passcode, connectCallback, errorCallback, vhost) {
var _this = this;
this.connectCallback = connectCallback;
if (typeof this.debug === "function") {
this.debug("Opening Web Socket...");
}
this.ws.onmessage = function (evt) {
var arr, c, data, frame, onreceive, _i, _len, _ref, _results;
data = typeof ArrayBuffer !== 'undefined' && evt.data instanceof ArrayBuffer ? (arr = new Uint8Array(evt.data), typeof _this.debug === "function" ? _this.debug("--- got data length: " + arr.length) : void 0, ((function () {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = arr.length; _i < _len; _i++) {
c = arr[_i];
_results.push(String.fromCharCode(c));
}
return _results;
})()).join('')) : evt.data;
_this.serverActivity = Date.now();
if (data === Byte.LF) {
if (typeof _this.debug === "function") {
_this.debug("<<< PONG");
}
return;
}
if (typeof _this.debug === "function") {
_this.debug("<<< " + data);
}
_ref = Frame.unmarshall(data);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
frame = _ref[_i];
switch (frame.command) {
case "CONNECTED":
if (typeof _this.debug === "function") {
_this.debug("connected to server " + frame.headers.server);
}
_this.connected = true;
_this._setupHeartbeat(frame.headers);
_results.push(typeof _this.connectCallback === "function" ? _this.connectCallback(frame) : void 0);
break;
case "MESSAGE":
onreceive = _this.subscriptions[frame.headers.subscription];
_results.push(typeof onreceive === "function" ? onreceive(frame) : void 0);
break;
case "RECEIPT":
_results.push(typeof _this.onreceipt === "function" ? _this.onreceipt(frame) : void 0);
break;
case "ERROR":
_results.push(typeof errorCallback === "function" ? errorCallback(frame) : void 0);
break;
default:
_results.push(typeof _this.debug === "function" ? _this.debug("Unhandled frame: " + frame) : void 0);
}
}
return _results;
};
this.ws.onclose = function () {
var msg;
msg = "Whoops! Lost connection to " + _this.ws.url;
if (typeof _this.debug === "function") {
_this.debug(msg);
}
_this._cleanUp();
return typeof errorCallback === "function" ? errorCallback(msg) : void 0;
};
return this.ws.onopen = function () {
var headers;
if (typeof _this.debug === "function") {
_this.debug('Web Socket Opened...');
}
headers = {
"accept-version": Stomp.VERSIONS.supportedVersions(),
"heart-beat": [_this.heartbeat.outgoing, _this.heartbeat.incoming].join(',')
};
if (vhost) {
headers.host = vhost;
}
if (login) {
headers.login = login;
}
if (passcode) {
headers.passcode = passcode;
}
return _this._transmit("CONNECT", headers);
};
}
IE8 给我错误"对象不支持此属性或方法"这一行:_this.serverActivity = Date.now();
.如果有人能对此有所了解,我将不胜感激?
IE8没有Date.now
,这是在ES5中添加的(所以,相对较近)。您可以添加它:
if (!Date.now) {
Date.now = function() {
return +new Date();
};
}
相关文章:
- 对象不支持属性或方法“自动完成”
- 对象不支持属性或方法“确认”
- 对象不支持属性或方法“jscomp_symbol_iterator0”
- 下拉 Javascript 错误:对象不支持属性或方法“匹配”
- 运行时错误:对象不支持属性或方法
- IE9:对象不支持属性“is”
- IE 错误 .JavaScript 运行时错误:对象不支持属性或方法“preventDefault”
- 对象不支持属性或方法“jtable”
- JavaScript 运行时错误:对象不支持属性或方法“包含”
- SCRIPT438:对象不支持属性或方法“委托”
- 对象不支持属性或方法“子项” 在 JStree 中重命名节点时
- 对象不支持属性或方法“plot”
- SCRIPT438:对象不支持属性或方法“on”
- IE8 addEventListener - Object 不支持属性或方法 'addEventListener
- 对象不支持属性或方法“删除”
- DatePicker 在完整视图中提供对象不支持属性或方法“日期选择器”,但不支持模态形式的属性或方法
- 对象没有'不支持属性或方法parseJSON
- 对象不支持属性或方法«_get_eventHandlerList»
- Gooddata Javascript API-不支持属性
- 对象中的jQuery分析HTML结果不支持属性错误