javascript 无法让 Chrome popup.js 使用 console.log
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14858909/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot get Chrome popup.js to use console.log
提问by gdanko
I use console.log heavily to debug when writing JS. I am trying to use it in writing chrome extensions but it is not working. Is there some trickery involved here???
我在写JS的时候大量使用console.log来调试。我正在尝试使用它来编写 chrome 扩展,但它不起作用。这里有什么诡计吗???
popup.html
弹出窗口.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link type="text/css" rel="stylesheet" href="css/jquery-ui-1.10.0.custom.min.css" />
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.10.0.custom.min.js"></script>
<script type="text/javascript" src="js/popup.js"></script>
</head>
<body style="width: 200px">
</body>
popup.js
弹出窗口.js
console.log('test1');
$(document).ready(function() {
console.log('test2');
});
Neither of these appear in the JS debugger.
这些都不会出现在 JS 调试器中。
回答by Sandeep Raju Prabhakar
I had this problem as well initially! Make sure you have correct developer tools window opened... I mean, you might have opened the developer tools window for the main page rather than the extension's page (ie. popup.html).
我一开始也有这个问题!确保您打开了正确的开发人员工具窗口...我的意思是,您可能打开了主页面的开发人员工具窗口,而不是扩展程序的页面(即 popup.html)。
To open the developer tools window for inspecting the popup, right click on the popup and then click 'inspect element'... That opens the right developer tools window.
要打开用于检查弹出窗口的开发人员工具窗口,请右键单击弹出窗口,然后单击“检查元素”...这将打开正确的开发人员工具窗口。
I had made this stupid mistake initially and was stuck.. :)
我最初犯了这个愚蠢的错误并被卡住了.. :)