2011-09-19 56 views
0

在我的网站,我有一个JavaScript文件的引用,并在IE浏览器,这个错误被抛出:错误的Javascript使网页在IE中停止运行的JavaScript

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; 
}, 

throw正在被互联网抓资源管理器,它似乎停止运行任何其他的JavaScript。

enter image description here

我能做些什么,这样的错误不会完全停止我的网页上的一切吗?

+0

唯一的例外是有效的,你在做什么,你需要禁用它? – davidfowl

回答

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; 
} 
+0

或只是console.error https://developer.mozilla.org/en-US/docs/Web/API/console.error –