开发者

google chrome extension: popup.html javascript vs jquery

I am playing around with extending google chrome and I have a simple extension running with the following popup.html file:

<script type = "text/javascript">
    alert("hi from popup.html");
</script>

<body>
Hello World
</body>

As soon as I add src attribute with the url to the google jquery CDN the 'alert("hi from popup.html");' no longer runs.

My manifest file looks like:

{
  "name": "My First Extension",
  "version": "1.0",
  "description": "The first extension that I made.",
  "background_page": "background.html",
  "browser_action": {
    "default_icon": "icon.png",
"popup": "popup.html"
  },
  "permissions": [
"tabs","ht开发者_开发百科tp://*/*","https://*/*"
  ]
}

Why does adding the jquery source break the popup?


You will need to break your scripts up into two statements. Try this:

<script type="text/javascript" src="jQuery.js"></script>
<script type="text/javascript">
    alert("hi from popup.html");
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜