2013-05-21 196 views
0

我有一個main.php文件,其中包含兩個I幀:test1test2加載iframe中的內容

<iframe id="test1" name="test1" src="test1.php" height="300" width="200"></iframe> 
<iframe id="test2" name="test2" src="test2.php"></iframe> 

#test1包含display: none;

我想顯示的test1.php當內容點擊test2.php處的按鈕。我已經嘗試了一些選項,並提到了與此問題有關的以前的帖子,但無法加載test1.php。我怎樣才能做到這一點?

+0

iFrame是幾乎總是一個壞主意,容易更換。 – 2013-05-21 21:23:44

+0

我不相信這是可能的,除非點擊事件iframe中的頁面位於您的服務器上,並且它發送了一個ajax請求,表明其他iframe中的頁面正在輪詢。 –

回答

0

編輯:我不確定你的意思是「加載」。最初是否加載了其他div的內容,而您只是試圖更改其可見性?還是你想改變iframe的全部內容?

案例1: 如果你想改變那些已經加載的iframe內容的可見性,當你按一下按鈕,然後檢查了這個問題:一旦你訪問該元素 Javascript - Get element from within an iFrame

你願意,你可以很容易地修改它的顯示屬性

案例2:如果你想改變iframe的全部內容,當你點擊按鈕 ,你需要改變它的src屬性。檢查這個問題的答案: Changing iframe src with Javascript

0

使用jQuery,當test2的一個按鈕被點擊使test1的顯示塊和TEST2顯示無反之亦然 $('#buttontest2').click(function() { $('#test1').css('display' : 'block'); })