简体   繁体   English

Chrome控制台JavaScript中是否显示所有错误?

[英]Are all errors shown in the Chrome console JavaScript errors?

Google Chrome, Firefox, and other browsers have a developer console to show errors. 谷歌浏览器,Firefox和其他浏览器都有一个显示错误的开发者控制台。 Are these the same errors that are triggered by window.onerror ? 这些是由window.onerror触发的相同错误吗?

The Chrome developer console is a superset of the information that is made available to window.onerror . Chrome开发者控制台是window.onerror可用信息的超集。 The developer console will show JavaScript errors, security errors, CSS errors, deprecation warnings, and many other internal faults in rendering the document. 开发人员控制台将在呈现文档时显示JavaScript错误,安全错误,CSS错误,弃用警告以及许多其他内部错误。

window.onerror is only unhandled global JavaScript errors. window.onerror只是未处理的全局JavaScript错误。

Another important difference is that the Developer Console will show the real, original error information whereas window.onerror might obfuscate the error message to "Script Error" if the error violates the Same Origin Policy . 另一个重要的区别是开发人员控制台将显示真实的原始错误信息,而如果错误违反同源策略window.onerror可能会将错误消息模糊到“脚本错误”。

The Chrome Developer console is a better set of information during development. Chrome Developer控制台在开发过程中是一组更好的信息。 Once you release your app, you should continue to trap and record errors from window.onerror so that you can be sure to know when your users run into problems. 一旦你发布你的应用程序,你应该继续陷阱并记录来自window.onerror错误,这样你就可以确定你的用户何时遇到问题。 The browser landscape is constantly changing, and you should know when something starts breaking. 浏览器的格局在不断变化,你应该知道什么时候开始破坏。 There are some good tools to help you do this automatically, like TrackJS . 有一些很好的工具可以帮助你自动完成这项工作,比如TrackJS Disclosure: I am one of the founding developers of TrackJS, so I've fixed a lot of js errors :) 披露:我是TrackJS的创始开发者之一,所以我修复了很多js错误:)

Unhandled javascript exceptions will raise the onerror event which you can handle. 未处理的javascript异常将引发您可以处理的onerror事件。

If you handle an exception in a try { ... } catch (e) { ... } block, whether it logs to the console is browser and setting specific. 如果您在try { ... } catch (e) { ... }块中处理异常,则它是否登录到控制台是浏览器和特定设置。

I am use firebug on FireFox,( You can use Break point, console.log(), errors,warnings,timeline,JS performance etc... ) I Suggestion you. 我在FireFox上使用firebug,(你可以使用Break point,console.log(),错误,警告,时间线,JS性能等...)我建议你。

Chrome https://getfirebug.com/releases/lite/chrome/ Chrome https://getfirebug.com/releases/lite/chrome/

Firefox https://addons.mozilla.org/en-us/firefox/addon/firebug/ Firefox https://addons.mozilla.org/en-us/firefox/addon/firebug/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM