Sunday, May 13, 2007

Adjust iframe Size to Fit its Contents

Sometimes we put iframe on HTML page and we need to adjust iframe size to fit its contents (iframe source HTML can be very big) ... Below is a small example that demonstrates how to do it:

< html>
< head>
< title>< /title>
< /head>

< body>
< iframe id="ifr" src="ifr.html">< /iframe>< br />
< input type="button" onclick="document.getElementById('ifr').style.height =
ifr.document.body.scrollHeight + 5" value="Ajust" />

< /body>
< /html>

No comments: