Home > Web Front-end > JS Tutorial > About JS method to determine whether the image is loaded and get the width of the image_javascript skills

About JS method to determine whether the image is loaded and get the width of the image_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:37:46
Original
1188 people have browsed it

Students who work on the web often encounter situations where customers upload pictures that burst the content area of ​​the web page. Here is a way to use js to deal with this problem. The specific idea is to judge the client's pictures in js After downloading, do some processing on the width or height of the image in a timely manner. JS processing of images mainly uses the Image object in JS to judge through the onload event and onreadystatechange.

(1) The first method, through the onload event, such as:

Copy the code The code is as follows:



(2) The second method, use onreadystatechange to judge

Copy code The code is as follows:


onloading……

Related labels:
js
source:php.cn
Statement of this Website
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
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template