Este artigo descreve o método de escala de mesma escala das imagens JS. Compartilhe -o para sua referência, como segue:
<! xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html; charset = gb2312"/> <title> title/title/title type = "text / javascript"> function automatia automática (maxwidth, maxHeight, objimg) {var iMg = new Image (); img.src = objimg.src; var hratio; var wratio; varo = 1; var w = img.width; /h; if (maxwidth == 0 && maxHeight == 0) {ratio = 1;} else if (maxwidth == 0) {// if (hratio <1) ratio = hratio;} else if (maxHeight == 0) {if (wratio <1) ratio = wratio; = (wratio <= hratio? wratio: hratio);} if (razão <1) {w = w * ratio; h = h * ratio;} objimg.Height = h; objimg.width = w;} </script> </headg> <body> <br 100) /> largura: 100px <r /> <r /> <img src = "1.jpg" onLload = "AutoresizeImage (0,100, this)" /> altura: 100px <Br /> <Br /> <img src = "1.jpg" onload = "AutoresizeImage (100,100, this)"> /> <r /> <r /> <r /> <r /> <r /> < /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 e Técnicas de Traversal "e" Resumo do Uso do Javascript Mathematic Operations "
Espero que este artigo seja útil para a programação JavaScript de todos.