The example in this article describes the way JavaScript limits the size of a picture display. Share to everyone for your reference. The implementation methods are as follows:
/**
* Limits the size of the picture display.
*
* @param thisobj Picture Component
* @param limitw limit width size
* @param limith Limit Height Size * *
function imageresize ( Thisobj, LIMITW, limith) {
var neww;
var newh;
if (Thisobj.width > LIMITW) {
neww = LIMITW;
NEWH = parseint (Thisobj.height * neww/thisobj.width);
Scale
if (Newh > Limith) {
NEWH = Limith by width scale;
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;
}
I hope this article will help you with your JavaScript programming.