0
Voici un court test pour illustrer mon problème. J'ai une page qui charge un iframe:jQuery signale une hauteur d'élément incorrecte dans Firefox iframe
<html>
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
</head>
<body>
<iframe id="iframe" src="box.html" style="width: 100px; height: 100px"></iframe>
<script>
$('#iframe').bind('load', function() {
var div = $(this).contents().find('div');
alert(div.height());
alert(div.innerHeight());
alert(div.outerHeight());
alert(div.outerHeight(true));
});
</script>
</body>
</html>
Le iframe (box.html) contient un seul div style:
<html>
<head>
<title></title>
<style>
div {
height: 50px;
width: 50px;
margin: 5px;
padding: 5px;
border: 2px solid #00f;
background-color: #f00;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
Les quatre alertes doivent revenir 50, 60, 64 et 74, respectivement . Cela fonctionne comme prévu dans Safari et Chrome. Dans FF 3.5.1, ils renvoient tous 64. C'est faux.
Est-ce que quelqu'un sait comment je peux forcer FF/jQuery à retourner les valeurs correctes?