Image Object
The Image object represents an HTML img element.
For each instance of an HTML <img> tag in a document, an Image
object is created.
The Image object's properties and events are
described below:
N: Netscape (including Mozilla when N6 or higher), IE: Internet Explorer, W3C: World Wide Web Consortium (Internet Standard)
Properties
Syntax: object.property_name
Property |
Description |
N |
IE |
W3C |
align |
Sets or returns how to align the image according to the
surrounding text |
6 |
5 |
Yes |
alt |
Sets or returns an alternate text to write if the image
cannot be displayed |
6 |
5 |
Yes |
border |
Sets or returns the width of the border of the image in pixels |
3 |
4 |
Yes |
complete |
Returns a Boolean value that indicates whether or not the
browser is finished loading the image |
3 |
4 |
No |
height |
Sets or returns the value of the height attribute of the <img> tag
in pixels |
3 |
4 |
Yes |
hspace |
Sets or returns the value of the hspace attribute of the <img> tag
in pixels |
3 |
4 |
Yes |
id |
Sets or returns the id of the image (In IE 4 this
property is read-only) |
|
4 |
No |
isMap |
Sets or returns a Boolean value that specifies if the image
is a server-side image map |
6 |
5 |
Yes |
longDesc |
Sets or returns a URL for a long description of the image |
|
6 |
Yes |
lowsrc |
Sets or returns a URL to a low-resolution version of the
image (for clients with low-resolution) |
3 |
4 |
No |
name |
Sets or returns the value of the name attribute of the <img> tag |
3 |
4 |
Yes |
src |
Sets or returns the URL of the image (This property can be
changed at any time. However, the new image is scaled to fit the height and
width attributes of the first image) |
3 |
4 |
Yes |
useMap |
Sets or returns a URL (often with a bookmark extension -
#name) to use as a client-side image map |
6 |
5 |
Yes |
vspace |
Sets or returns the value of the vspace attribute of the <img> tag
in pixels |
3 |
4 |
Yes |
width |
Sets or returns the value of the width attribute of the <img> tag
in pixels |
3 |
4 |
Yes |
Methods
Syntax: object.method_name()
Method |
Description |
N |
IE |
W3C |
blur() |
Removes focus from the image |
|
4 |
No |
click() |
Simulates a mouse-click on the image |
|
4 |
No |
focus() |
Gives focus to the image |
|
4 |
No |
Events
Syntax: object.event_name="someJavaScriptCode"
Event |
Description |
N |
IE |
W3C |
onAbort |
Executes some code when a user aborts the download of an
image |
3 |
4 |
|
onBlur |
Executes some code when the image loses focus |
|
4 |
|
onClick |
Executes some code when a user clicks on the image |
|
4 |
|
onError |
Executes some code when an Error occurs |
3 |
4 |
|
onFocus |
Executes some code when the image gets focus |
|
4 |
|
onLoad |
Executes some code when the image loads |
3 |
4 |
|
|