如何将JQuery ui加载到chrome扩展内容脚本中?

时间:2014-06-25 21:15:46

标签: google-chrome-extension

我试图将jquery ui加载到chrome扩展名中。

我已经成功加载jquery.jsjquery-ui.jsjquery-ui.css但是当我打开一个对话框时, 对话框的图像(如关闭按钮的x)没有显示,我收到警告:

Resource interpreted as Image but transferred with MIME type text/html: ...

我还尝试将jquery-ui.cssimages/image_name更改为chrome://extension/__extension__ID__/images/image_name。然后我收到错误:

not allowed to load local resource: ...

这样做的正确方法是什么?

我的manifest.json看起来像:

{
    "name": "my_extension",
    "version": "0.0.2",
    "description": "bla bla",
    "permissions": [
        "activeTab",
        "tabs",
        "http://*/"
    ],
    "background": { "scripts": ["background.js"] },
    "content_scripts": [ {
        "js": [ "jquery-1.10.2.js" , "jquery-ui-1.10.4.custom.min.js" ],
        "css": [ "jquery-ui-1.10.4.custom.min.css" ],
        "matches": [ "http://*/*", "https://*/*"]
    }],
    "web_accessible_resources": [
        "images/*"
    ],
    "browser_action": {
        "default_title": "Run",
        "default_icon": "Run.png"
    },
  "manifest_version": 2
}

1 个答案:

答案 0 :(得分:1)

您需要从清单中将其设为web_accesible_resource并使用chrome.extension.getUrl获取其实际网址