2012-06-03 44 views
3

當用戶單擊圖標時,彈出一個popup.html文件。 popup.html有一個按鈕。如果點擊此按鈕,我想在關閉當前彈出窗口後顯示來自不同html文件的另一個彈出窗口。有誰知道如何做到這一點(我已經有一個listner附加到我的按鈕,我想知道的是關閉當前顯示的彈出窗口並打開一個新窗口)。動態替換popup.html

回答

0

彈出窗口就像常規選項卡,所以window.location.href="..."對它們起作用。

但是,您可以在彈出窗口中簡單地彈出覆蓋圖和全屏iframe,並在其上覆蓋一個關閉按鈕。

<iframe src="http://target.com" style="position:absolute; left:0; top:0; right:0; bottom:0; width:... 

等等。

+0

好。我想我應該更清楚一點,但我想削減代碼,只發布相關部分。整個popup.html不僅包含一個按鈕,而且還包含文本字段等其他元素。現在將這個i框架加載到當前框架上會導致動畫在後臺持續運行。有沒有辦法可以將popup.html動態替換爲antoher文件。如果這是唯一的方式,請您發佈一些代碼,以便如何動態關閉iframe – user1092042

+0

Chrome擴展彈出窗口不支持'window。 location.href'到另一個網頁。 – morha13

0

您可以使用innerHTML更新彈出頁面動態

var event_container; 
    event_container = document.getElementById('element ID');//Get location of event container 
    event_container.innerHTML = event_container.innerHTML + "html string you want to add";