Sunday, 8 July 2012

Post Data to an iframe


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:
&ltp>I’m probably being loaded inside an iframe.&lt/p>
&ltp>Text value: &lt?php echo $_POST["text"]; ?>&lt/p>

No comments:

Post a Comment

Physics basic inventions and inventors

1.Which instrument is used to measure altitudes in aircraft's ? Audiometer Ammeter Altimeter Anemometer Explanation : ...