Iframe et hauteur automatique
Fermé
wrea
-
3 mai 2007 à 23:44
gwenm Messages postés 591 Date d'inscription lundi 6 octobre 2008 Statut Membre Dernière intervention 11 février 2016 - 20 déc. 2011 à 14:24
gwenm Messages postés 591 Date d'inscription lundi 6 octobre 2008 Statut Membre Dernière intervention 11 février 2016 - 20 déc. 2011 à 14:24
A voir également:
- Iframe hauteur automatique
- Message automatique thunderbird - Guide
- Longueur largeur hauteur ✓ - Forum Loisirs / Divertissements
- Réponse automatique outlook - Guide
- Recherche automatique des chaînes ne fonctionne pas - 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>
30 janv. 2010 à 19:09
8 sept. 2011 à 19:47
Il suffit de mettre un height:100%; à l'iframe et définir une hauteur aux éléments parents (ne pas oublier la balise html)
20 déc. 2011 à 14:24