我有一个弹出窗口,可以在文档就绪上运行javascript并重定向更改popup.html以进行另一个...这是最明显的
@import "../scss/test";
popup.js
{
"manifest_version": 2,
"name": "My App",
"description": "Lorem ipsum",
"version": "1.0",
"background": {
"persistent": false,
"scripts": ["js/jquery-2.2.3.min.js", "background/background.js"]
},
"content_scripts": [
{
"matches": ["*"],
"js": ["js/jquery-2.2.3.min.js", "content/buttons.js"]
}
],
"web_accessible_resources": ["content/*.html"],
"browser_action": {
"default_icon": "favicon-96x96.png",
"default_popup": "popup/index/index.html"
},
"permissions": [
"tabs", "webNavigation", "notifications", "*://localhost/*", "http://127.0.0.1/*"
]
}
我的list.html在弹出窗口上呈现没有任何问题,它看起来像这样:
//Some code that runs correctly
chrome.browserAction.setPopup("list/list.html");
如您所见,最后我插入了list.js,但无论我做什么,这都不会在list.html加载时运行...
我到处检查过,但我不知道错误可能在哪里。
这是list.js
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../main.css">
<title>TaskCrusher</title>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">MyApp</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><a class="logout-button" href="#" onclick="return logOut();">Logout</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<h4>Welcome!</h4>
</body>
<script src="../../js/jquery-2.2.3.min.js"></script>
<script type="application/javascript" src="../../js/bootstrap.min.js"> </script>
<script type="application/javascript" src="../global.js"></script>
<script type="application/javascript" src="../../js/carhartl-jquery-cookie/jquery.cookie.js"></script>
<script type="application/javascript" src="../../js/notifyjs/notify.min.js"></script>
<script type="application/javascript" src="list.js"></script>
</html>
我尝试使用$(checkCardWaiting)和$(document).ready(checkCardWaiting),但是当我调试时,我发现它甚至没有运行代码。此外,当我调试时,我看到在源选项卡中下载的js文件。
提前多多谢谢你。
答案 0 :(得分:0)
我的坏。实际上它正在运行。我认为这不是因为我在弹出窗口上使用了chrome调试器而且它没有在任何断点处停止。但我放了一个console.log命令,他们确实运行了。在没有重新加载扩展的情况下尝试全部,我看到第三次运行代码时调试器开始在断点处停止...所以这是一个调试器问题。