A voir également:
- Iframe hauteur automatique
- Réponse automatique thunderbird - Guide
- Longueur largeur hauteur ✓ - Forum Loisirs / Divertissements
- Recherche automatique des chaînes ne fonctionne pas - Guide
- Logiciel de sauvegarde automatique gratuit - Guide
- Sommaire automatique word - Guide
5 réponses
Voici un code qui fonctionne bien! J'ai galérer aussi ;-)
<html>
<script type="text/javascript">
function autoIframe(frameId){
try{
frame = document.getElementById(frameId);
innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
objToResize = (frame.style) ? frame.style : frame;
objToResize.height = innerDoc.body.scrollHeight + 10;
}
catch(err){
window.status = err.message;
}
}
</script>
<body>
<iframe id="tree" name="tree" src="tree.htm" onload="if (window.parent && window.parent.autoIframe) {window.parent.autoIframe('tree');}"></iframe>
</body>
</html>
<html>
<script type="text/javascript">
function autoIframe(frameId){
try{
frame = document.getElementById(frameId);
innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
objToResize = (frame.style) ? frame.style : frame;
objToResize.height = innerDoc.body.scrollHeight + 10;
}
catch(err){
window.status = err.message;
}
}
</script>
<body>
<iframe id="tree" name="tree" src="tree.htm" onload="if (window.parent && window.parent.autoIframe) {window.parent.autoIframe('tree');}"></iframe>
</body>
</html>
Il suffit de mettre un height:100%; à l'iframe et définir une hauteur aux éléments parents (ne pas oublier la balise html)