【发布时间】:2013-11-21 19:20:28
【问题描述】:
我无法从我的扩展程序的 background.js 脚本访问活动选项卡(页面)的 html 代码
manifest.json
"background": {
"scripts": ["jquery.js","background.js"]
},
background.js
chrome.webRequest.onBeforeRequest.addListener(
function(info) {
return {redirectUrl: "http://www.mysite.com/script.php?" +
"data=" + encodeURIComponent($('#J_Data').text())};
},
{
urls: [
"http://www.othersite.com/addItems.do*"
],
types: ["script"]
},
["blocking"]);
但是 background.js 无法访问活动页面 html 代码并且 "$('#J_Data').text()" 未定义! 如何使用 background.js 和 jQuery 访问活动页面?
【问题讨论】:
标签: javascript jquery google-chrome-extension