我正在尝试为Google Chrome创建一个简单的扩展程序。我包括了我已经使用的代码。但是包含的脚本不起作用。
index.html
<!doctype html>
<html>
<head>
<script src="ext.js"></script>
</head>
<body>
<button id='test'>Test</button>
<body>
</html>
manifest.json
{
"name": "Demo Extension",
"description": "Demo Extension",
"version": "1.0",
"permissions": ["tabs", "http://*/*", "https://*/*"],
"browser_action": {
"default_title": "Demo",
"default_popup": "index.html"
},
"content_security_policy":"script-src 'self' https://localhost; object-src 'self'",
"manifest_version": 2
}
ext.js
function clickHandler(e) {
alert('its working');
}
document.addEventListener('DOMContentReady', function () {
document.querySelector('button')
.addEventListener('click', clickHandler);
});
我该如何解决?
它是DOMContentLoaded而不是DOMContentReady-devnull69
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句