Home >Web Front-end >JS Tutorial >Example of JS proportionally reducing image size_javascript skills

Example of JS proportionally reducing image size_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:41:181134browse

In order to improve user experience, when website users upload images, we cannot allow users to process the images themselves to meet our requirements.

Usually for pages like the physical display of goods on Taobao, the main thing we need to control is the width of the image.

Considering some problems that may be caused by the parsing order of HTML pages, we decided to implement it by defining a simple function and then adding an onload event to the img element to call it. The code is as follows:

JS part

Copy code The code is as follows:







HTML calling part


Copy code

The code is as follows:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn