问题描述
我看过很多关于这个问题的帖子,但是似乎没有一个解决方案对我有用。我有一个带有背景,popup.html和popup.js的简单清单。脚本似乎没有执行任何操作(只是试图获取警报)。我正在尝试找出某个地方是否缺少某些东西(希望我没有犯过一个真正愚蠢的错误)。
manifest.json
{
"name": "ext","version": "1.0","description":"ext","permissions": ["declarativeContent","activeTab"],"background": {
"scripts": ["background.js"],"persistent":false
},"browser_action": {
"default_popup": "popup.html","default_icon": {
"16": "16_px_icon.ico"
}
},"icons": {
"16": "16_px_icon.ico"
},"manifest_version": 2
}
background.js
chrome.runtime.onInstalled.addListener(function() {
chrome.storage.sync.set({saves:[]} );
});
chrome.declarativeContent.onPageChanged.removeRules(undefined,function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: {hostEquals: 'developer.chrome.com'},})
],actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
popup.html
<!DOCTYPE html>
<html>
<head>
<style>
button {
height: 30px;
width: 60px;
outline:none;
}
</style>
<script type="text/javascript" scr="popup.js" ></script>
</head>
<body>
<input type="text" id="Fd">
<button id="Btn">
Search</button>
<span id="Msg"></span>
</body>
</html>
popup.js
function search() {
alert('A')
}
window.onload = function() {
//document.getElementById('Btn').addEventListener('click',search); tried this
document.getElementById('Btn').onclick = search;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)