Image heightPropriété
Objet Image
Définition et utilisation
La propriété height définit ou renvoie la valeur de l'attribut height d'une image.
L'attribut height spécifie la hauteur d'une image.
Syntaxe
imageObject.height=pixels
Prise en charge des navigateurs
![]()
![]()
![]()
![]()
![]()
Tous les principaux navigateurs prennent en charge la propriété height.
Exemples
Exemples
L'exemple suivant définit la hauteur et la largeur d'une image :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function changeSize(){
document.getElementById("compman").height="250";
document.getElementById("compman").width="300";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif.html" width="107" height="98">
<br><br>
<input type="button" onclick="changeSize()" value="Changer la taille de l'image">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function changeSize(){
document.getElementById("compman").height="250";
document.getElementById("compman").width="300";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif.html" width="107" height="98">
<br><br>
<input type="button" onclick="changeSize()" value="Changer la taille de l'image">
</body>
</html>
Essayez-le vous-même »
Objet Image Autres extensions