Fungovanie tejto stránky je z dôvodu údržby dočasne obmedzené. Ak článok nevyrieši váš problém a chcete položiť otázku, napíšte našej komunite podpory na Twitter @FirefoxSupport alebo Reddit /r/firefox.

Vyhľadajte odpoveď

Vyhnite sa podvodom s podporou. Nikdy vás nebudeme žiadať, aby ste zavolali alebo poslali SMS na telefónne číslo alebo zdieľali osobné informácie. Nahláste prosím podozrivú aktivitu použitím voľby “Nahlásiť zneužitie”.

Ďalšie informácie

Determine iFrame height dynamically?

  • 1 odpoveď
  • 24 má tento problém
  • 1 zobrazenie
  • Posledná odpoveď od cor-el

more options

I am loading a PHP-based webpage inside an iframe of another webpage. As I understand, the iframe has exactly one event that can be used by Javascript: onload. With this event, I am able to size the iframe to the size of the content.

However, if the height of the inner page changes, I cannot resize the iframe to fit the inner page's new height. This causes two scrollbars to appear: one attached to the inner webpage, and one attached to the outer webpage (which the iframe resides in). The outer scrollbar is acceptable by the users, but the inner one is not -- it creates navigation problems and other confusion.

I cannot fix this via Javascript (that I know of), since these webpages are on different sites, and will cause cross-site errors. I cannot ask the users to allow cross-site exceptions. I am not able to change the iframe size using innerHTML -- the innerHMTL.height does *not* change when the HTML content grows in height; instead, a scrollbar appears at that point, and the height remains the same.

All that is needed, really, is *dynamic* access to the inner HTML's dimensions. (This may require another event within the iframe object, something like onInnerHTMLChange; however, other solutions can be found if the innerHTML height is accessible.)

What I would like to know is if there is any way to resize the iframe according to the dynamic height of the content. Also, am I right in understanding that an iframe is actually another browser window object?

I am loading a PHP-based webpage inside an iframe of another webpage. As I understand, the iframe has exactly one event that can be used by Javascript: onload. With this event, I am able to size the iframe to the size of the content. However, if the height of the inner page changes, I cannot resize the iframe to fit the inner page's new height. This causes two scrollbars to appear: one attached to the inner webpage, and one attached to the outer webpage (which the iframe resides in). The outer scrollbar is acceptable by the users, but the inner one is not -- it creates navigation problems and other confusion. I cannot fix this via Javascript (that I know of), since these webpages are on different sites, and will cause cross-site errors. I cannot ask the users to allow cross-site exceptions. I am not able to change the iframe size using innerHTML -- the innerHMTL.height does *not* change when the HTML content grows in height; instead, a scrollbar appears at that point, and the height remains the same. All that is needed, really, is *dynamic* access to the inner HTML's dimensions. (This may require another event within the iframe object, something like onInnerHTMLChange; however, other solutions can be found if the innerHTML height is accessible.) What I would like to know is if there is any way to resize the iframe according to the dynamic height of the content. Also, am I right in understanding that an iframe is actually another browser window object?

Upravil(a) delfeld dňa

Všetky odpovede (1)

more options

You can ask questions and advice about web development at the mozillaZine Web Development/Standards Evangelism forum.

A good place to ask questions and advice about web development is at the mozillaZine Web Development/Standards Evangelism forum.

The helpers at that forum are more knowledgeable about web development issues.

You need to register at the mozillaZine forum site in order to post at that forum.

See http://forums.mozillazine.org/viewforum.php?f=25