在我的网站上,我有一个javascript文件的引用,在IE上,抛出了这个错误:
send: function (data) {
/// <summary>Sends data over the connection</summary>
/// <param name="data" type="String">The data to send over the connection</param>
/// <returns type="signalR" />
var connection = this;
if (!connection.transport) {
// Connection hasn't been started yet
throw "SignalR: Connection must be started before data can be sent. Call .start() before .send()";
}
connection.transport.send(connection, data);
return connection;
},
Internet Explorer正在捕获throw
,它似乎暂停了其他任何javascript的运行。
我该怎么做才能让错误无法完全停止我页面上的所有内容?
答案 0 :(得分:1)
如果你不想抛出异常,为什么要使用throw? 考虑这一点,如果您想要用于记录目的的异常:
if (!connection.transport) {
// Connection hasn't been started yet
setTimeout(function() {
throw "SignalR: Connection must be started before data can be sent. Call .start() before .send()";
}, 0);
return;
}