Ce site disposera de fonctionnalités limitées pendant que nous effectuons des opérations de maintenance en vue de vous proposer un meilleur service. Si un article ne règle pas votre problème et que vous souhaitez poser une question, notre communauté d’assistance est prête à vous répondre via @FirefoxSupport sur Twitter, et /r/firefox sur Reddit.

Rechercher dans l’assistance

Évitez les escroqueries à l’assistance. Nous ne vous demanderons jamais d’appeler ou d’envoyer un SMS à un numéro de téléphone ou de partager des informations personnelles. Veuillez signaler toute activité suspecte en utilisant l’option « Signaler un abus ».

En savoir plus

Determine iFrame height dynamically?

  • 1 réponse
  • 24 ont ce problème
  • 1 vue
  • Dernière réponse par 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?

Modifié le par delfeld

Toutes les réponses (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