简体   繁体   English

如何在Chrome扩展程序内容脚本中快速查看解析错误?

[英]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检查器顶部的工具栏中(“检查元素”时弹出的窗口/窗格),单击最右边的按钮/选项卡“控制台”,如下所示:

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.

相关问题 "<i>How can I fetch data in my content script?<\/i>如何在我的内容脚本中获取数据?<\/b> <i>(chrome extension)<\/i> (镀铬扩展)<\/b>" - How can I fetch data in my content script? (chrome extension) 如何在后台获取chrome扩展程序的内容脚本? - How can I get chrome extension's content script to in the background? 如何确定Chrome扩展程序是否位于内容脚本的弹出窗口中? - How can I determine if a Chrome extension is in a popup from the content script? 如何在 chrome 扩展内容脚本中使用 google api? - How can I use google api in chrome extension content script? 如何在Chrome扩展程序内容脚本中获取错误堆栈跟踪? - How to get errors stack trace in Chrome extension content script? Chrome扩展程序:如何在全局范围内捕获/处理内容脚本错误? - Chrome extension: how to trap/handle content-script errors globally? 如何通过内容脚本将模板中的 HTML 插入 Chrome 扩展程序中的 div - How do I insert the HTML from a template into my div in my Chrome extension via a content script Chrome 扩展程序:如何获取 web 页面以访问我的内容脚本定义的功能? - Chrome Extension: How do I get a web page to access functions defined by my content script? Chrome扩展程序如何将我的内容脚本注入所有Facebook页面 - Chrome extension how to inject my content script into all Facebook pages 当页面上已有旧版本时,如何在chrome扩展内容脚本中使用jquery - How can I use jquery in a chrome extension content script when an older version is already on the page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM