我目前有一个像这样的 JavaScript 错误处理程序:
window.onerror = function(msg, url, line){ //stuff }};
但我希望能够使用 jquery 附加到 onerror,如下所示:
$(window).error(function(evtData){//stuff});
我的问题是,从 jquery 的 eventData 对象中,我如何获取错误的消息、url 和行号,就像我在非 jquery 函数中所做的那样?
提前致谢。
最佳答案
来自 jQuery 文档。
Note: A jQuery error event handler should not be attached to the window object. The browser fires the window's error event when a script error occurs. However, the window error event receives different arguments and has different return value requirements than conventional event handlers. Use window.onerror instead.
关于javascript - 从 jquery 的 eventData 对象获取错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9317291/