Following is my code of HTML
Scripts:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="background.js"></script>
HTML:
<button name="btnlogin" id="btnlogin">Login</button><br/><br/>
and following is js
$(document).ready(function(){
document.getElementById("#btnlogin").click(function(){
alert("s");
});
});
manifest file:
{
"manifest_version": 2,
"name": "One-click Kittens",
"description": "This extension demonstrates a 'browser action' with kittens.",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
}
I found that when I run this code simply in browser than alert appears properly but when I run it as a chrome extension it gives me following errors.
Uncaught ReferenceError: $ is not defined
and
Refused to load the script 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js' because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:".
I don't understand what are these errors. Please help me understanding the extension..
Thank you
$ is not defined
means jquery wasn't loaded, and the second message is telling you the reason why jquery wasn't loaded. You should show us your manifest for the extension. Here are the docs for extension manifests: developer.chrome.com/extensions/manifest – Octavie