Perfect compatibility with multi-browser js judgment image path code summarization _ javascript tips-js tutorial

Source: Internet
Author: User
This article summarizes and shares several types of codes that use javascript to determine whether an image path exists. They are all used in projects in normal times. Here, we will summarize the Code. If you need it, you can refer to it. Method 1

// Check whether the Image has function CheckImgExists (imgurl) {var ImgObj = new Image (); // check whether the Image has ImgObj. src = imgurl; // if no image exists,-1if (ImgObj. fileSize> 0 | (ImgObj. width> 0 & ImgObj. height> 0) {alert (imgurl + 'exist');} else {alert (imgurl + 'nonexistent ');}} checkImgExists ('/editor/simple/FileIconDir/rar.gif'); CheckImgExists ('/editor/simple/FileIconDir/rarsdfs.gif ');

Another Implementation Method

The Code is as follows:

Method 3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.