谷歌浏览器扩展:popup.html javascript 与 jquery

发布于 2024-11-04 16:16:17 字数 661 浏览 0 评论 0原文

我正在扩展 google chrome,我有一个简单的扩展程序,运行以下 popup.html 文件:

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

<body>
Hello World
</body>

一旦我将 src 属性和 url 添加到 google jquery CDN 'alert("hi from popup.html") ;'不再运行。

我的清单文件如下所示:

{
  "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","http://*/*","https://*/*"
  ]
}

为什么添加 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","http://*/*","https://*/*"
  ]
}

Why does adding the jquery source break the popup?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

窝囊感情。 2024-11-11 16:16:17

您需要将脚本分成两个语句。试试这个:

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

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文