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">
<iframe name="my-iframe" src="iframe.php"></iframe>

The outer page doesn’t …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Resize Iframe to Fit Content (Same Domain Only)

Normally you set and width and height for iframes. If the content inside is bigger, scrollbars have to suffice. The script below attempts to fix that by dynamically resizing the iframe to fit the content it loads.

<script type='text/javascript' src=''></script>
Avatar of Chris Coyier
Chris Coyier on (Updated on )