window.onerror没有捕获所有错误 [英] window.onerror does not catch all errors

查看:200
本文介绍了window.onerror没有捕获所有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,除了不安全的JavaScript尝试使用URL访问框架之外,我还可以捕获所有控制台错误。有没有人知道为什么错误被过滤?

For some reason I am able to catch all of the console errors except for "Unsafe JavaScript attempt to access frame with URL". Does anyone know why that error is filtered?

我的代码:

window.onerror = function(message) { alert(message); return true; };

感谢前方

推荐答案


可能的重复:

  • Display Javascript "same origin policy" violations
  • Catching same origin exception in Javascript?

我不知道这是否是检测相同来源政策违规,因为窗口.onerror 仅捕获运行时JS错误(请参阅 here )。

I am not sure if that's the way to detect Same origin policy violations, since the window.onerror only catches runtime JS errors (see here).

对于错误事件的跨浏览器兼容性可以查看:

For cross browser compatibility of error event you can check this out:

http://www.quirksmode.org/dom/events/error.html

这篇关于window.onerror没有捕获所有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆