Fonction ratioImage (resize d'image propotionnel) incompatible IE9
Bonjour,
La fonction ratioImage (ci-dessous) n'est pas compatible avec IE9 :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<script language="javascript">
function ratioImage(urlImage,largeurImg){
photo=new Image();
photo.src=urlImage;
var photoWidth=photo.width;
var photoHeight=photo.height;
var ratio=(Math.round((largeurImg/photoWidth)*100))/100;
var newPhotoWidth=photoWidth*ratio;
var newPhotoHeight=photoHeight*ratio;
document.write("<img class=\"image_presentation\" src=\"" + urlImage + "\" width=\"" + newPhotoWidth + "\" height=\"" + newPhotoHeight+ "\" />");
};
</script> |
A appeler comme ceci :
Code:
1 2 3
| <script language="javascript">
ratioImage("http://www.clickonmylinks.fr/wp-content/images/singe1.jpg",100)
</script> |
Auriez-vous une solution de remplacement pour cette fonction ?
D'avance merci.