Este artículo describe el método para limitar el tamaño de la pantalla de imagen en JavaScript. Compártelo para su referencia. El método de implementación específico es el siguiente:
/*** Limite el tamaño de la pantalla de imagen. ** @param thisObj Componente de imagen* @param Limitw Limite el tamaño de ancho* @param Limith Limit the Wize de altura*/función ImageSize (thisObj, Limitw, Limith) {var neww; var newh; if (thisObj.Width> Limitw) {neww = Limitw; newh = parseInt (thisObj.Height * neww / thisObj.width); // escala por ancho 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 artículo sea útil para la programación de JavaScript de todos.