5
我已閱讀文檔,但仍無法使其工作。來自background.js的內容腳本中的Chrome調用函數
這裏是我的清單:
{
"name":"app",
"version":"0.1",
"manifest_version":2,
"description":"app",
"background":{
"scripts":[
"scripts/modernizr.min.js",
"scripts/background.js"
],
"persistent": false
},
"content_scripts": [
{
"matches": ["https://*/*", "http://*/*"],
"js": ["scripts/content.js"],
"run_at": "document_end"
}
],
"permissions":[
"contextMenus",
"tabs",
"http://*/*",
"https://*/*"
],
"icons":{
"16":"images/icon_16.png",
"128":"images/icon_128.png"
}
}
我有content.js稱爲 「myFunc的」 功能。在background.js中,我有一個函數,「myHandler」由contextMenus.onClicked偵聽器調用。我想從myHandler調用myFunc。我嘗試使用tabs.executeScript和tabs.query,但我似乎無法獲得被調用的函數。任何人都可以向我解釋我應該如何讓background.js在content.js中調用一個函數?
要添加這個API是在過去2年發生變化,這就是它的外觀,現在。 – vittore
@vittore啊,這可能可以解釋爲什麼我試圖不工作。 – Lebowski156