user5635857
user5635857

Reputation:

Html not recognizing JavaScript (Chrome Extension)

I'm making a Chrome Extension and my HTML is not picking up any JavaScript.

HTML Head:

<script src="application.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

jQuery (The alerts are here for testing purposes):

$(document).ready(function () {
alert("hello");
$(".box").click(function () {

  alert("box");
  $("webview").show(1000); 
  $(".content").slideUp();

});

$(".webHome").click(function () {
  $(".content").show(1000);
});
});

Manifest.json:

{
  "update_url": "https://clients2.google.com/service/update2/crx",

  "name": "ChromeApps",
  "version": "1.0",
  "manifest_version": 2,
  "icons": {
  "128": "logo.png"
},
"app": {
  "background": {
    "scripts": [ "background.js", "application.js" ],
    "persistent": false
  }
},
"permissions": ["webview"],
"kiosk_enabled": true

All my files are definitely in the same folder. I feel like there is something in the manifest that I'm missing.

Upvotes: 1

Views: 275

Answers (1)

Xan
Xan

Reputation: 77482

Your manifest is a manifest for a Chrome App, not an Extension.

With that in mind, Chrome Apps cannot use remote code, so you can't include jQuery from a CDN.

You need to include a local copy of jquery.min.js and include it in the same way as application.js.

Also, don't forget that order matters: you need to load jQuery before using it.

Upvotes: 2

Related Questions