javascript js设置页面标题 js获取网页标题 - 不能使用注入的jQuery
1
Answers
动态修改title 获取网页title js修改title
我想在Chrome扩展中将jQuery注入到网页(带有内容脚本)中。
我尝试,但有些困惑。
这是我的manifest.json
:
{
"name": "test",
"description": "test content script.",
"version": "0.0.1",
"background": {
"scripts": ["jquery-1.10.2.js", "popup.js"]
},
"permissions": ["tabs", "notifications", "http://*/*", "https://*/*"],
"browser_action": {
"default_title": "test",
"default_icon": "icon.png"
},
"options_page": "manage.html",
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["jquery-1.10.2.js"]
}
],
"manifest_version": 2
}
jquery-1.10.2.js :
/*jquery's orign code*/
console.log("end of jquery");
我可以看到控制台消息,但我仍然不能使用jQuery。
我写了一个简单的网站,试图通过内容脚本包含jQuery,而不是添加一个<script>
标签。
在Dev Tool控制台中,输入window.jQuery
或$("li").siblings()
。
如果在页面中包含jQuery,它可以工作,但是如果它被注入一个内容脚本,它将显示jQuery
为undefined。
为什么会发生?
0 votes
javascript