gpt4 book ai didi

javascript - 从 jquery 的 eventData 对象获取错误信息

转载 作者:行者123 更新时间:2023-11-29 17:25:16 27 4
gpt4 key购买 nike

我目前有一个像这样的 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.

引用:http://api.jquery.com/error/

关于javascript - 从 jquery 的 eventData 对象获取错误信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9317291/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com