2012-09-06 64 views
4

這似乎是一個古老的問題。但我似乎無法找到解決辦法。從一個iframe發佈到另一個iframe - IE

我有一個頁面上有兩個iframe。它們是這樣加載的:

<iframe id="leftIframe" src="predict_goalkeepers.php" height="900" width="300" frameBorder="0" hspace="0"></iframe> <iframe id="rightIframe" src="predict_right.php" height="900" width="300" frameBorder="0" hspace="0"></iframe> 

然後我想從左側的幀向右發佈一些東西,同時刷新左側的幀。這是我通過目標框架和onclick函數完成的。在左邊我有這個:

<form action="predict_rightframe.php" method="post" name="form1" id="form1" target="rightIframe"><input type="checkbox" name="goalkeepers" value="1" onclick="this.form.submit(); window.location.reload(true)"> 

這在Chrome上可以正常工作,超級不錯。但是在檢查Firefox和IE時,框架會在新窗口中打開。

反正有這個嗎?

我相信有一個「黑客」,你可以通過javascript來創建一個框架。但只有建議我發現是如何創建一個隱藏的框架(see here)但我希望這個框架是可見的。

在這個問題上的任何幫助將是非常有幫助的 - 即使它只是適應上述鏈接的JavaScript代碼來創建一個可見的iframe。

+0

只是一個想法,但你有沒有嘗試將'window.location.reload'替換爲'location.reload'?這應該意味着最接近的'window'對象,IE iFrame ... –

+0

我會做的。但重載功能在所有瀏覽器上都正常工作。它是表單位的發佈不起作用 - 表單的結果在新窗口中打開,而不是在正確的Iframe中打開。 – Mrchuckles

+0

哦,那麼確保你已經在'' –

回答

0

我修好了!這花了我幾個小時的時間。

但是如果有人有同樣的問題。下面是解..

創建一個名爲frame.js這些細節文件:

var filePath = 'predict_rightframe.php'; 
// Setup the iframe target 
var iframe='<iframe id="myIframe" name="myIframe" src ="predict_rightframe.php" width="300" height="450" marginheight="0" marginwidth="0" frameborder="no" scrolling="no"></iframe>'; 
// Write the iframe to the page 
document.write(iframe); 

var myIframe = parent.document.getElementById("frame"); 
// Setup the width and height 
myIframe.height = 450; 
myIframe.width = 300; 

myIframe.src = filePath; 
// set the style of the iframe 
myIframe.style.border = "0px solid #999"; 
myIframe.style.padding = "0px"; 

然後你想要的iframe出現只是把:

<script language="JavaScript" src="includes/frame.js"></script> 

我不是過於肯定爲什麼這會起作用(坦率地說,我不在乎它的工作原理!)。這與IE沒有想到iframe是一個對象有關。 Javascript可以讓IE認爲它是一個對象...現在反正它工作。

相關問題