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

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

问题描述

出于某种原因,我能捕获所有控制台的错误,除了不安全的JavaScript的尝试与URL访问框架。有谁知道为什么被过滤的错误?

我的code:

  window.onerror =功能(消息){警报(消息);返回true; };

由于提前


解决方案

  

可能的复制:


  
  

我不知道这是检测相同的方式来源政策违规行为,因为 window.onerror 只捕获的运行JS错误的(见的这里)。

有关错误事件的跨浏览器兼容,你可以检查了这一点:

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

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?

my code:

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

Thanks ahead

解决方案

Possible duplicate:

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天全站免登陆