2013-02-01 147 views
2

這是我從IFRAME提交表單後關閉它提交和顯示隱藏的div

<html> 
    <head> 
    </head> 
    <body> 
    <iframe id="myiframe"> 
    <form id= "myform" action="submit.php" method="POST"> 
    <input type="submit"> 
    </form></iframe> 
    <div id="hiddendiv" style="display:none"> 
    some text 
    </div> 
    </body></html> 

,這是我想在iframe提交表單(醚通過後落得什麼進入或只需點擊按鈕提交,我不在乎,因爲表格只有1場)

<html> 
    <head> 
    </head> 
    <body> 
    //I want this iframe to become display:none or to be deleted 
    /*<iframe id="myiframe"> 
    <form id= "myform" action="submit.php" method="POST"> 
    <input type="submit"> 
    </form></iframe>*/ 
    //and this div to be showed 
    <div id="hiddendiv" style="display:"> 
    some text 
    </div> 
    </body></html> 

可以請人幫助,謝謝

我有answare但我必須等待8個小時,職位是如此我edite d最初的問題,你可以鍋,如果你想這樣我就可以確認它作爲一個answare

得到它

<html> 
<head> 
</head> 
<body> 
<script> 

function closeIframe() { 
var iframe = document.getElementById('myiframe'); 
iframe.parentNode.removeChild(iframe); 
document.getElementById("hiddendiv").style.display=""; 
} 

</script> 
<iframe id="myiframe"> 
<form id= "myform" action="submit.php" method="POST"> 
<input type="submit"> 
</form></iframe> 
<div id="hiddendiv" style="display:none"> 
some text 
</div> 
</body></html> 

,並在submit.php回報是這個

echo '<script type="text/javascript">'; 
echo 'parent.closeIframe()'; 
echo '</script>'; 

回答

1
<html> 
<head> 
</head> 
<body> 
<script> 

function closeIframe() { 
var iframe = document.getElementById('myiframe'); 
iframe.parentNode.removeChild(iframe); 
document.getElementById("hiddendiv").style.display=""; 
} 

</script> 
<iframe id="myiframe"> 
<form id= "myform" action="submit.php" method="POST"> 
<input type="submit"> 
</form></iframe> 
<div id="hiddendiv" style="display:none"> 
some text 
</div> 
</body></html> 

,並在submit.php回報是這個

echo '<script type="text/javascript">'; 
echo 'parent.closeIframe()'; 
echo '</script>'; 
1

如果來自同一域名,請將其添加到submit.php並提取表單以放入iframe 您需要

<iframe src="form.html"></iframe> 

DEMO

<script> 
top.document.getElementById("myiframe").style.display="none";   
top.document.getElementById("hiddendiv").style.display="block"; 
</script> 
+0

:)我知道你知道你在說什麼,但我不知道如何實現 – user2031113

+0

所以提交.php是我的情況下的郵件程序。所以我可以把類似的東西,如果電子郵件發送返回.....我怎麼在PHP中制定代碼? – user2031113

+0

查看更新.............. – mplungjan