Javascript is a method for obtaining the width and height of an image.

Source: Internet
Author: User

You can use javascript to obtain the width and height of an image. To prevent data errors caused by incomplete image loading, the onreadystatechange event ensures the width of the image, high data accuracy. The Code is as follows:

Var image = new Image (); image. src = 'HTTP: // loads () {if (image. readyState = 'complete') {alert ("the width and height of the image obtained through js are:" + image. width + '-' + image. height );}}
Articles you may be interested in
  • Js address bar special effects (display the size of all images with links on the page and view the height of the current browser)
  • Js checks whether the image is loaded and obtains the image width.
  • Php obtains the screen width, height, and resolution of the client computer.
  • Automatically adjust the image width during webpage Loading
  • Js obtains the height of the scroll bar from the top and bottom of the browser. It is compatible with ie and firefox.
  • Powerful PHP image processing class (watermark, transparency, zoom, sharpen, rotate, flip, cut, reversed)
  • JQuery obtains the height and width of the visible area of the browser window, and the height of the scroll bar.
  • Image zoom-in display special effects slimbox the most lightweight function the most powerful Jquery Image zoom-in special effects

Related Article

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.