如果代码中有不同域的请求发出, 浏览器因为同源策略的原因会拦截该请求并在 Console 中打印出错误信息.
例如 "XMLHttpRequest cannot load http://dtoweb.com/post/cross-origin-solution-summary.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access."
但是使用 window.onerror 并不能捕获到这个错误消息, 像这种类型的错误, 有办法可以捕捉到吗?
问题来了, 存在 window.onerror 捕捉不到的错误吗?