Name
Image — an <img> in an HTML document
Inherits from
Node, Element
Synopsis
An Image object represents an image embedded in an HTML
document with an <img> tag.
The images that appear in a document are collected in the document.images[] array.
The src property of the
Image object is the most interesting one. When you set this
property, the browser loads and displays the image specified by the
new value. This allows visual effects such as image rollovers and
animations. See Scripting Images for
examples.
You can create offscreen Image objects by simply creating new
<img> elements with document
.createElement() or with
the Image() constructor. Note
that this constructor does not have an argument to specify the image
to be loaded: to load an image, simply set the src property of your Image object. To
actually display the image, insert the Image object into the
document.
Constructor
newImage([unsignedlongwidth,unsignedlongheight])
You can create a new Image as you would create any HTML
element with document. create
Element(). For
historical reasons, however, client-side JavaScript also defines the
Image() constructor to do the
same thing. If the width or
height arguments are specified, they set
the width and height attributes of the <img> tag.
Properties
In addition to the properties listed here, Image elements also
expose the following HTML attributes as JavaScript properties:
alt, usemap, ismap.
readonly booleancompletetrueif no imagesrcwas specified or if the image has been completely ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access