将JQuery加载到Chrome扩展中? [英] Load JQuery into a Chrome extension?
本文介绍了将JQuery加载到Chrome扩展中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将JQuery加载到我的Chrome扩展程序中,并将它与一个对象等同起来,但我想知道我该如何解决这个问题?基本上我会喜欢...
jQuery = loadLibraries(jquery-1.4.2.min.js) ;
我会怎么做?
编辑:我正在注入内容脚本。
解决方案
您可以将jquery.js放入扩展文件夹并将其包含在清单:
{
name:我的扩展,
...
content_scripts:[
{
matches:[http://www.google.com/*],
css:[mystyles.css] ,
js:[jquery.js,myscript.js]
}
],
...
}
当内容脚本被沙箱化时,您不必担心与父页面上的jQuery发生冲突。
I'm attempting to load JQuery into my Chrome extension and make it equal to an object but I'm wondering how would I go about this? basically I'd like something like...
jQuery = loadLibraries("jquery-1.4.2.min.js");
How would I do this?
edit: I'm injecting into content script.
解决方案
You can just put jquery.js into extension folder and include it in the manifest:
{
"name": "My extension",
...
"content_scripts": [
{
"matches": ["http://www.google.com/*"],
"css": ["mystyles.css"],
"js": ["jquery.js", "myscript.js"]
}
],
...
}
You don't need to worry about conflicts with jQuery on a parent page as content scripts are sandboxed.
这篇关于将JQuery加载到Chrome扩展中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文