简体   繁体   English

如何在我的manifest.json文件中包括jQuery扩展的jQuery

[英]How to include jQuery in my manifest.json file for a chrome Extension

I have read many answers on here, but none of the solutions have worked. 我在这里阅读了许多答案,但是没有一种解决方案有效。 I know I am doing something wrong, so I would be very grateful if somebody had the time to help me here. 我知道我做错了,所以如果有人有时间在这里帮助我,我将不胜感激。

File-name for my JS-file is main.js 我的JS文件的文件名为main.js

My relevant HTML-Code: 我相关的HTML代码:

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

My entire manifest.json: 我的整个manifest.json:

"name": "Roasts Tab",
"manifest_version": 2,
"description": "A fire roast every time you open a new tab in Chrome",
"version": "0.0.0.1",
"permissions": ["management"],
"chrome_url_overrides": {
"newtab": "index.html"
 },
 "icons": {
 "128": "icon.png"
 }
 }

Thanks in advance. 提前致谢。

You have two src attributes on your first script tag... It looks like you need to remove the src="jquery.js" one, since you're loading jQuery from the cdn. 您的第一个脚本标签上有两个src属性...看来您需要删除src="jquery.js"一个,因为您是从cdn加载jQuery的。

Also move your own script tag below the jQuery cdn script tag. 还要将您自己的脚本标签移动到jQuery cdn脚本标签下方。 As it is now, it runs your scripts first, and then loads jQuery after, so your scripts do not have access to the jQuery functions. 到目前为止,它先运行您的脚本,然后再加载jQuery,因此您的脚本无权访问jQuery函数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Chrome扩展程序:Manifest.json在选项中包含JS - Chrome Extension: Manifest.json include JS in options Chrome 扩展程序,如何在 manifest.json 中排除 chrome:// URI - Chrome extension, how to exclude chrome:// URIs in manifest.json 制作 manifest.json 文件时 Chrome 扩展程序错误 - Chrome extension error while making manifest.json file 在Chrome扩展manifest.json中检测锚点 - Detect anchor in Chrome Extension manifest.json 如何访问 Firefox 扩展的 manifest.json 文件? - How to access the manifest.json file of a Firefox extension? 在 Chrome 扩展清单 v3 中,我如何指示 manifest.json 仅在某些网页上运行我的扩展而不使用 activeTab 权限? - In Chrome extension Manifest v3, how do i instruct manifest.json to run my extension only on certain webpages without using activeTab permission? 在Google Chrome扩展程序manifest.json中启用跨域权限 - Enable cross domain permission in google chrome extension manifest.json Chrome扩展程序-manifest.json加载文件夹中的所有js - Chrome Extension - manifest.json load all js in folder 如何从Chrome扩展程序的选项页面启用/禁用manifest.json CSS内容脚本? - How to enable/disable manifest.json CSS content script from Chrome Extension's options page? 如何在 Chrome Extension Manifest.json 中设置内容安全策略以使 Firebase 工作 - How to set Content Security Policy in Chrome Extension Manifest.json in order for Firebase to work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM