新しいタブを開くpopup.htmlのボタン付きChrome拡張機能を使用しています。新しいタブのリンク先URLには、現在の(元の)タブの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});
});
})
新しいタブが完全に開かれますが、URLはhttp://www.mydestination.com/index.php?url=undefined
(URLです=未定義)。
私はmanifest.jsonを右権限を保持数える:適切に運ばURLを取得する方法について
{
"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"
}
}
任意の手掛かりを?
、「タブ」は、実際にクリックイベントになり、あなたは 'のaddEventListener(「クリック」、機能(EVT、タブを){意味いけない...' – 1337holiday