Este artigo descreve o método de limitar o tamanho da exibição da imagem em JavaScript. Compartilhe para sua referência. O método de implementação específico é o seguinte:
/*** Limite o tamanho da exibição da imagem. ** @param thisObj Image Component* @param limitew limite o tamanho da largura* @param limite limite o tamanho da altura*/função imageResize (thisobj, limitew, limith) {var neww; var newh; if (thisobj.width> limitew) {neww = limitew; newh = parseint (thisObj.Height * neww / thisobj.width); // escala por largura if (newh> limith) {newh = limith; neww = parseint (thisObj.width * newh / thisobj.Height); } thisobj.width = neww; thisObj.Height = newh; } else if (thisObj.Height> limith) {newh = limith; neww = parseint (thisObj.width * newh / thisobj.Height); thisobj.width = neww; thisObj.Height = newh; }}Espero que este artigo seja útil para a programação JavaScript de todos.