[英]How can I quickly see parsing errors in my chrome extension content script?
I can use chrome's "inspect element" feature to view and debug my javascript, but only if it has successfully loaded. 我可以使用chrome的“检查元素”功能来查看和调试我的JavaScript,但前提是必须成功加载它。 If the script has a parsing error then it doesn't load and isn't shown via "inspect element". 如果脚本有解析错误,则它不会加载,也不会通过“检查元素”显示。
How can I get chrome to show me its attempt to parse my script and a list of errors it has encountered? 如何获得chrome向我展示尝试解析脚本以及遇到的错误列表的尝试?
I'm a newb to both chrome extensions and javascript, so apologies if I'm missing something obvious. 我是chrome扩展程序和javascript的新手,因此如果我遗漏了一些明显的内容,我们深表歉意。
In the toolbar at the top of the Web Inspector (the window/pane that pops up when you "Inspect Element") click on the right-most button/tab, "Console," as seen here: 在Web检查器顶部的工具栏中(“检查元素”时弹出的窗口/窗格),单击最右边的按钮/选项卡“控制台”,如下所示:
Not only will this show you all of the errors the page generates (JavaScript and others), it's also a full JavaScript REPL so you can interact with the page by entering any JavaScript you want. 这不仅会向您显示页面生成的所有错误(JavaScript和其他错误),而且还是完整的JavaScript REPL,因此您可以通过输入所需的任何JavaScript与页面进行交互。
Jordan has the right answer (should have seen that, I knew it was a newb question!), but while I was searching I also came across JSLint , which is quite useful. Jordan给出了正确的答案(应该知道,我知道这是一个新问题!),但是在搜索时,我还遇到了JSLint ,这非常有用。 It's stricter than the chrome execution engine, so it generates a bunch of warnings you may not need to worry about, but still handy. 它比chrome执行引擎更严格,因此它会生成许多警告,您可能不必担心,但仍然很方便。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.