faqts : Computers : Programming : Languages : JavaScript : Frames

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

54 of 69 people (78%) answered Yes
Recently 9 of 10 people (90%) answered Yes


How can I dynamically change the size of an IFrame thru a link in that iFrame?

Jul 28th, 2004 10:31
Kristen Bains, zachary shwaluk,

If you have iframe content that contains links, you can dynamically
change the size of the iframe to reflect the size of the new content as
function change_height() {
    if(document.getElementById && !(document.all)) {
      height =
       document.getElementById('myiframe').style.height = height;
    else if(document.all) {
        height = document.frames('myiframe').document.body.scrollHeight;
        document.all.myiframe.style.height = height;
<iframe id="myiframe" onLoad="change_height()" src="src.html"
scrolling="auto" height="100"></iframe>
This should work in both the newer IE and Netscape, but hasn't been
tested in older browsers or other browsers.