Javascript 错误导致 IE 中的页面停止运行 javascript
在我的网站上,我引用了一个 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 的运行。
我该怎么做才能使错误不会完全停止页面上的所有内容?
On my website, I have a reference to a javascript file, and on IE, this error is thrown:
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;
},
That throw
is being caught by Internet Explorer, and it appears to halt any other javascript from running.
What can I do so that error doesn't completely halt everything on my page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你不想抛出异常,为什么还要使用 throw 呢?
如果您希望出于日志记录目的而例外,请考虑这一点:
Why are you using throw if you don't want to throw the exception?
consider this, if you want the exception for logging purposes: