Name

Image: an image in an HTML document — DOM Level 2 HTML: Node → Element → HTMLElement → Image

Constructor

new Image(integerwidth, integer height)

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 a name 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

deprecated String align

align

Alignment with respect to inline content

String alt

alt

Alternate text when image can’t be displayed

deprecated String border

border

Size of image border

long height

height

Image height, in pixels

deprecated long hspace

hspace

Left and right margins, in pixels

boolean isMap

ismap

Whether to use a server-side image map

String longDesc

longdesc

The URI of a long image description

String useMap ...

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.