Post Data to an iframe
Doesn't take any JavaScript or anything. You just have the form's target attribute match the iframe's name attribute.
<form action="iframe.php" target="my-iframe" method="post">
<label for="text">Some text:</label>
<input type="text" name="text" id="text">
<input type="submit" value="post">
</form>
<iframe name="my-iframe" src="iframe.php"></iframe>
The outer page doesn't even reload. But it might appear to at first glance since many browsers run the page-loading spinner in the tab when an iframe reloads.
If anyone else is having problems making this work try this for the iframe.php page:
<p>I’m probably being loaded inside an iframe.</p>
<p>Text value: <?php echo $_POST["text"]; ?></p>
No comments:
Post a Comment