0
我有我的谷歌擴展的問題,我已經按照我認爲正確的信息發送到後臺頁面,但是當我嘗試運行我的擴展我打「未捕獲TypeError:對象[對象DOMWindow]沒有方法「更近」「有誰知道發生了什麼,爲什麼?問題獲得背景頁面
popup.html
var i = 0;
function start(){
var bg = chrome.extension.getBackgroundPage();
bg.closer(i); //chrome.extension.sendRequest({});
}
function add(){
i++;
document.getElementById('box').value=i;
}
function sub(){
i--;
document.getElementById('box').value=i;
}
background.html
var ctr = 0;
function closer(int i){
var t=setTimeout("close()",i*500);
}
function close(){
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.remove(tab.id, function() { });
});
}
的manifest.json
{
"name": "Hello World!",
"version": "1.0",
"description": "My first Chrome extension.",
"permissions": ["tabs", "background"],
"background_page": "background.html",
"browser_action": {
"default_icon": "icon.png",
"popup": "popup.html"
}
}
那麼什麼是getBackgroundPage();意味着用於? – easilyBaffled 2012-02-07 21:34:50
如果您想從該頁面獲取數據,您仍然可以在該頁面上閱讀DOM。此外,您可以關閉popup.hmtl中的標籤頁。 – tomdemuyt 2012-02-07 21:55:37
我可以關閉彈出窗口中的選項卡,但據我所知,如果我按下開始並彈出消失,那麼延遲關閉的計數器號碼將立即消失,這不是我正在嘗試做的。 – easilyBaffled 2012-02-08 04:52:14