this is what I have
<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>
and this is what I want to end up with after the form in the iframe is submitted (ether by enter or just clicking the button submit, I do not care because the form only has 1 field)
<html>
<head>
</head>
<body>
//I want this iframe to bee 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>
can anyone please help, thanks
i have the answare but I have to wait for 8 h to post is so I edited the initial question, you can pot is if you want so I can validate it as a answare
got it
<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>
and in the submit.php the return is this
echo '<script type="text/javascript">';
echo 'parent.closeIframe()';
echo '</script>';
this is what I have
<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>
and this is what I want to end up with after the form in the iframe is submitted (ether by enter or just clicking the button submit, I do not care because the form only has 1 field)
<html>
<head>
</head>
<body>
//I want this iframe to bee 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>
can anyone please help, thanks
i have the answare but I have to wait for 8 h to post is so I edited the initial question, you can pot is if you want so I can validate it as a answare
got it
<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>
and in the submit.php the return is this
echo '<script type="text/javascript">';
echo 'parent.closeIframe()';
echo '</script>';
Share
edited Feb 1, 2013 at 14:29
user2031113
asked Feb 1, 2013 at 11:48
user2031113user2031113
932 gold badges3 silver badges7 bronze badges
2 Answers
Reset to default 1If from same domain, add this in the submit.php and extract the form to put in the iframe You need
<iframe src="form.html"></iframe>
DEMO
<script>
top.document.getElementById("myiframe").style.display="none";
top.document.getElementById("hiddendiv").style.display="block";
</script>
<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>
and in the submit.php the return is this
echo '<script type="text/javascript">';
echo 'parent.closeIframe()';
echo '</script>';