这就是我所拥有的
<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>
谁能帮忙,谢谢
我有答案,但我必须等待 8 小时才能发布,所以我编辑了最初的问题,如果你愿意,你可以将其验证为答案
知道了
<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>';