Name
Image: an image in an HTML document — DOM Level 2 HTML: Node → Element → HTMLElement → Image
Constructor
new Image(integerwidth
, integerheight
)
Arguments
width
,height
An optionally specified width and height for the image.
Properties
-
String name
This property specifies the name for the image object. If an
<img>
tag has aname
attribute, you can access the corresponding Image object as a named property of the Document object.-
String src
A read/write string that specifies the URL of the image to be displayed by the browser. The initial value of this property is specified by the
src
attribute of the<img>
tag. When you set this property to the URL of a new image, the browser loads and displays that new image. This is useful for updating the graphical appearance of your web pages in response to user actions and can also be used to perform simple animation.
In addition to these properties, Image objects also support the following properties, which simply mirror HTML attributes:
Property |
Attribute |
Description |
|
|
Alignment with respect to inline content |
|
|
Alternate text when image can’t be displayed |
|
|
Size of image border |
|
|
Image height, in pixels |
|
|
Left and right margins, in pixels |
|
|
Whether to use a server-side image map |
|
|
The URI of a long image description |
|
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.