这就是我所拥有的
<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小时才能发布,所以我编辑了最初的问题,如果你愿意,可以使用pot,我可以将其验证为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>';
答案 0 :(得分:1)
如果来自同一个域,请在submit.php中添加此项并提取表单以放入iframe 你需要
<iframe src="form.html"></iframe>
<script>
top.document.getElementById("myiframe").style.display="none";
top.document.getElementById("hiddendiv").style.display="block";
</script>
答案 1 :(得分: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>';