我想提出一個有兩個模式的Chrome擴展,並且每當圖標點擊彈出應該出現消息,解釋到他是在什麼模式下,用戶。JavaScript的彈出消息僅出現一次
問題是該消息不會始終顯示(彈出窗口本身被打開)。
我試過Google搜索它,但似乎沒有很多人遇到過這個問題。
任何人都可以幫忙嗎?
這裏是我的代碼:
function openWin1()
{
myWindow=window.open('','','width=500,height=500,toolbar=0, location=0, status=0, menubar=0, scrollbars=0, resizable=0');
myWindow.moveTo(500,100);
myWindow.document.write("<p>mode1</p>");
myWindow.focus();
}
function openWin2()
{
myWindow=window.open('','','width=500,height=500,toolbar=0, location=0, status=0, menubar=0, scrollbars=0, resizable=0');
myWindow.moveTo(500,100);
myWindow.document.write("<p>mode2</p>");
myWindow.focus();
}
chrome.browserAction.onClicked.addListener(onClickExtensionIcon);
function onClickExtensionIcon(tab)
{
if(hasAPrise)
{
hasAPrise = false;
chrome.browserAction.setIcon({path: '/icon.png'});
openWin1(); //open the first popup
}
else
{
openWin2(); //open the second popup
}
}
在此先感謝
編輯:我注意到,如果我最大化和幾次儘量減少彈出,消息確實出現。另外,當我檢查彈出源時,它的消息是正確的。這很有趣。任何想法如何解決這一問題。
沒有得到顯示什麼信息?我在代碼中看不到一個。 – Moob
'myWindow.document.write(「
mode1
」);和myWindow.document.write(「mode2
」);'當打開第一個彈出窗口應該說mode1,第二個應該說mode2 – r3x