我在popup.html中使用了一個Chrome擴展,並在其中打開了一個新選項卡。新選項卡的目標網址將當前(原始)選項卡的URL保存爲參數。Chrome擴展程序tab.url undefined
例如:從http://stackoverflow.com/
發射時,新標籤應該有一個像http://www.mydestination.com/index.php?url=http://stackoverflow.com/
這裏的URL是我的JS:
document.addEventListener('DOMContentLoaded', function (tab) {
document.getElementById('button').addEventListener("click", function(tab) {
chrome.tabs.create({url: 'http://www.mydestination.com/index.php?url=' + tab.url});
});
})
新的標籤是完全打開的,但是網址是http://www.mydestination.com/index.php?url=undefined
(URL =未定義)。
我認爲對於manifest.json持有正確的權限:
{
"manifest_version": 2,
"name": "My project",
"version" : "1.7",
"browser_action": {
"default_icon" : "img/icon.png",
"default_title" : "My project",
"default_popup": "html/main.html"
},
"permissions": [
"tabs"
],
"icons": {
"16": "img/icon.png"
}
}
如何獲取URL運輸不當任何線索?
哇等待, 「標籤」 實際上是click事件,不要你的意思'的addEventListener( 「點擊」,函數(EVT,標籤){...' – 1337holiday 2013-05-13 02:20:28