简体   繁体   English

编写Chrome扩展程序时如何调试Javascript错误?

[英]How can I debug Javascript errors while writing Chrome extensions?

How can I see javascript error when loading chrome extensions? 加载Chrome扩展程序时如何查看JavaScript错误? I've tried using developer tools but I don't see any errors there. 我曾尝试使用开发人员工具,但那里没有看到任何错误。 Also if I use console.log , I don't see any output in the console. 另外,如果我使用console.log ,则在控制台中看不到任何输出。

Anyone have any ideas? 有人有想法么?

http://code.google.com/chrome/extensions/tut_debugging.html http://code.google.com/chrome/extensions/tut_debugging.html

  1. Go to the Extensions page (chrome://extensions), and make sure Developer mode is still enabled. 转到“扩展程序”页面(chrome:// extensions),并确保仍启用“开发人员”模式。 The Extensions page doesn't need to be open for the following to work. 无需打开“扩展”页面即可执行以下操作。 The browser remembers the setting, even when the page isn't shown. 即使页面未显示,浏览器也会记住该设置。

  2. Right-click the extension's icon and choose the Inspect popup menu item. 右键单击扩展程序的图标,然后选择“检查”弹出菜单项。 The popup appears, and a Developer Tools window like the following should display the code for popup.html. 出现弹出窗口,并且如下所示的“开发人员工具”窗口应显示popup.html的代码。

The above answer doesn't work anymore. 上面的答案不再起作用。 Sadly the Inspect Popup menu item has been removed from Chrome. 遗憾的是,“检查弹出窗口”菜单项已从Chrome中删除。

But this answer works: Debug popup.html of a Chrome Extension? 但这答案有效: 调试Chrome扩展程序的popup.html吗?

(More precisely: the second comment of the first answer on the above page helps). (更准确地说:上页第一个答案的第二条评论会有所帮助)。

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

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