Welcome to %s forums

<No. 1 Community for developers, by developers/>

Login Register

How to post data to an Iframe?

For general web development questions using HTML and CSS.
Post Reply
admin
Site Admin
Posts: 45

How to post data to an Iframe?

Post by admin » Thu Aug 22, 2019 2:41 pm

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.

Code: Select all

<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>

Code: Select all

<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.

Post Reply