Cet article décrit la méthode de mise à l'échelle de même échelle des images JS. Partagez-le pour votre référence, comme suit:
<! Doctype html public "- // w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml"> <éread> <meta http-equiv = "content-type" content = "text / html; charset = gb2312" /> <t titre> javascript affiche automatique type = "text / javascript"> function autoRoreSizeImage (maxwidth, maxheight, objimg) {var img = new image (); img.src = objimg.src; var hratio; var wratio; var ratio = 1; var w = img.width; var h = iMg.height; wratio = maxwidth / w; h; hratio = maxheight; wratio = maxwidth / w; h; hratio = maxheight; wratio = maxwidth / w; h; hratio = maxheight; wratio = maxwidth / w; h; hratio = maxheight; wratio = maxwidth / w; h; hratio = maxHeight; / h; if (maxwidth == 0 && maxHeight == 0) {ratio = 1;} else if (maxwidth == 0) {// if (hratio <1) ratio = hraRio;} else if (maxheight == 0) {if (wratio <1) ratio = wratio;} else if (wratio <1 | hento <1) = (wratio <= hratio? wratio: hratio);} if (ratio <1) {w = w * ratio; h = h * ratio;} objimg.height = h; objimg.width = w;} </ script> </ head> <body> <br /> <img src = "1.jpg" /> Largeur: 100px <r /> <br /> <img src = "1.jpg" onload = "autoresizeImage (0,100, this)" /> height: 100px <roRoreSing /> <br /> <br /> <br /> <br /> <br /> </ body> </html>Pour plus d'informations sur le contenu lié à JavaScript, veuillez consulter les sujets de ce site: "Résumé des effets et techniques de commutation JavaScript", "Résumé des effets et techniques de recherche JavaScript", "Résumé des erreurs Javascript et des techniques de débogage" Algorithmes et techniques de traversée JavaScript ", et" Résumé de l'utilisation des opérations mathématiques JavaScript "
J'espère que cet article sera utile à la programmation JavaScript de tous.