2015-04-05 323 views
0

我已經添加了以下iFrame的頁面使用iframe和頁面覆蓋動態

<iframe src='http://redbug.redrocksoftware.com.au:80/Pages/chamara.html' style="position:absolute;z-index:1;" ></iframe> 

chamara.html頁面包含一個按鈕,當我點擊該按鈕,我需要在當前頁面過於掩飾。

反饋是內部的iframe按鈕: enter image description here

當我點擊它,我需要像下面的情況發生。

enter image description here

我試圖用IFRAME絕對定位和z-index的,但不能得到任何工作還沒有。

+0

是否iframe要覆蓋所有的頁面?按鈕覆蓋是否覆蓋了所有的iframe? – 2015-04-05 05:11:00

+0

@RafaelAlmeida號這只是一個iframe添加到另一個頁面內,我需要它來動態覆蓋整個頁面 – chamara 2015-04-05 05:13:42

+0

默認覆蓋整個頁面,或僅當反饋按鈕被觸發時覆蓋整個頁面?默認情況下,嘗試它:'iframe {position:absolute;頂部:0;左:0;寬度:100%;高度:100%;的z-index:999; }' – 2015-04-05 05:15:49

回答

1

哈哈,終於完成了演示! :P

好吧,我們走吧。如果你需要iframe覆蓋整個頁面,只有當他的按鈕被觸發時,你可以使用jQuery來處理click事件。您需要使用contents()獲取iframe內容,然後使用find()獲取所需的元素。基本上這樣的:

$("#iframe").contents().find("#iframe_button").click(function() { 
    // Button fired! 
}) 

要的iframe覆蓋我寫這個CSS類的所有頁面:

.iframe_cover { 
    position:absolute; 
    top:0; 
    left:0; 
    width:100% !important; 
    height:100% !important; 
    border:0; 
} 

所以,當按鈕被觸發時,iframe將這個類。看:

$("#iframe").contents().find("#iframe_button").click(function() { 
    $("#iframe").addClass("iframe_cover"); 
}) 

演示:http://rafaelalmeida.net78.net/exemplos/soen/29454285-iframe-button/

+0

謝謝你的幫助朋友。 – chamara 2015-04-05 06:05:11

+0

不客氣:) – 2015-04-05 06:05:40