Este artículo describe el método de escala de la misma escala de las imágenes JS. Compártelo para su referencia, como sigue:
< xmlns = "http://www.w3.org/1999/xhtml"> <fead> <meta http-equiv = "content-type" content = "text/html; charset = gb2312"/> <title> javaScript muestra automáticamente imágenes en proporción, compresas imágenes en proporción </title> type = "text / javaScript"> function AutoresizeImage (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; hratio; maxHeight/h; if (maxwidth == 0 && maxheight == 0) {ratio = 1;} else if (maxwidth == 0) {// if (hratio <1) ratio = hratio;} else if (maxheight == 0) {if (wratio <1) rato = wratio;} else if (if (jew hratio <1) {ratio = (wratio <= hratio? wratio: hratio);} if (ratio <1) {w = w * ratio; h = h * ratio;} objimg.height = h; objimg.width = w;} </script> </head> <body> <r/> <IMG src = " onload = "AutoresizeImage (100,0, este)" /> ancho: 100px <Br /> <Br /> <img src = "1.jpg" onload = "AutoresizeImage (0,100, this)" /> Height: 100px <Br /> <Br /> <img src = "1.jpg" onload = "AutoresizeImage (100,100, esto). Altura: 100px <Br /> <Br /> <Br /> <Br /> <Br /> <Br /> <Br /> <Br /> </body> < /html>For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm skills", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm skills", "Summary of JavaScript Algoritmos y técnicas de recorrido ", y" Resumen del uso de operaciones matemáticas de JavaScript "
Espero que este artículo sea útil para la programación de JavaScript de todos.