![](/img/trans.png)
[英]How to include jQuery in my manifest.json file for a chrome Extension
[英]Chrome Extension: Manifest.json include JS in options
基本問題,在manifest.json中的“ options_page”中包含javascript的最佳方法是什么? 可以肯定的是,我遇到了兩個錯誤,即如何包含js以及如何包含頁面的命名/參數。
任何幫助都將是驚人的!
下面是我得到錯誤的地方:
{
"name": " name of app",
"version": "0.1",
"description": "app stuff",
"background": {
"page": "background.html"
},
"manifest_version": 2,
"browser_action": {
"name": "Manipulate DOM",
"icons": ["icon.png"],
"default_icon": "icon.png"
},
"options_ui": {
// Required.
"page": "options.html",
"js": "options.js", // the file i'm trying to add (for fun)
"chrome_style": true,
}, //where chrome keeps flagging the error.
"content_scripts": [{
"js": ["jquery-2.0.2.min.js", "background.js"],
"css": ["customStyles.css"],
"matches": ["http://*/*", "https://*/*"]
}]
}
您需要從"chrome_style": true,
刪除逗號"chrome_style": true,
您無需在清單中包括選項腳本。 只需聲明html頁面並將腳本作為<script>
添加到html中即可。 您的選項頁面不與其他網站共享dom,因此它沒有如此廣泛的安全限制。
<script src="options.js"></script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.