Reputation: 11
I am trying to create a simple extension for google chrome. I am including the code that I have used. But the script included is not working.
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);
});
How can I resolve this?
Upvotes: 1
Views: 89
Reputation: 18650
It's DOMContentLoaded rather than DOMContentReady - devnull69
Upvotes: 1