Anatoly Lubarsky

Logo
MSSQL, .NET, Design. Life and Music

Javascript Tip: 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>

Related Posts:

Sunday, May 23, 2004 5:31 AM

Comments

# re: HowTo: Adjust Iframe
Good One. Helped me a lot

7/15/2004 2:00 PM by Amith

# re: Javascript: Adjust Iframe
OR

<iframe name="ifr" id="ifr" src="whatever.html" onload="this.style.height = ifr.document.body.scrollHeight + 5"></iframe>

3/22/2006 10:33 PM by Harry

If your feedback doesn't appear right away, please be patient as it may take a few minutes to publish.

Post a Comment

Protected by CAPTCHAEnter the code you see
Name (*)  
E-mail (*)  
Url
Remember

Comment (*)