Venant de refaire mon site et étant embêté avec le dimensionnement des Iframes qui sont fixes et peuvent parfois faire des pages longues pour rien du tout (particulièrement sur les stats NOAA).
J'ai fini par trouver un bout de code pour que la longueur s'adapte automatiquement. J'ai testé sur les dernières versions de IE, FF, Chrome et Opera.
A mettre dans <head> (changer indexInlineFrame1 par le nom de votre iframe) :
Code : Tout sélectionner
<script type="text/javascript">
/* free code from dyn-web.com */
function getDocHeight(doc) {
doc = doc || document;
// from http://stackoverflow.com/questions/1145850/get-height-of-entire-document-with-javascript
var body = doc.body, html = doc.documentElement;
var height = Math.max( body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight );
return height;
}
function setIframeHeight(id) {
var indexInlineFrame1 = document.getElementById(id);
var doc = indexInlineFrame1.contentDocument? indexInlineFrame1.contentDocument: indexInlineFrame1.contentWindow.document;
indexInlineFrame1.style.visibility = 'hidden';
indexInlineFrame1.style.height = "10px"; // reset to minimal height in case going from longer to shorter doc
indexInlineFrame1.style.height = getDocHeight( doc ) + "px";
indexInlineFrame1.style.visibility = 'visible';
}
</script>
Code : Tout sélectionner
<iframe name="indexInlineFrame1" id="indexInlineFrame1" src="./page1.html" onload="setIframeHeight(this.id)" style="position:absolute;text-align:center;left:167px;top:115px;width:920px;" scrolling="no"></iframe>
http://www.willmaster.com/library/tutor ... hanges.php
Bonne journée.