Javascript 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.
IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).
Javascript Image Object Properties
Property |
Description |
IE |
F |
N |
W3C |
align |
Sets or returns how to align the image according to the surrounding text |
5 |
1 |
6 |
Yes |
alt |
Sets or returns an alternate text to write if the image cannot be displayed |
5 |
1 |
6 |
Yes |
border |
Sets or returns the width of the border of the image in pixels |
4 |
1 |
3 |
Yes |
complete |
Returns a Boolean value that indicates whether or not the browser is finished loading the image |
4 |
1 |
3 |
No |
height |
Sets or returns the value of the height attribute of the <img> tag in pixels |
4 |
1 |
3 |
Yes |
hspace |
Sets or returns the value of the hspace attribute of the <img> tag in pixels |
4 |
1 |
3 |
Yes |
id |
Sets or returns the id of the image (In IE 4 this property is read-only) |
4 |
1 |
|
No |
isMap |
Sets or returns a Boolean value that specifies if the image is a server-side image map |
5 |
1 |
6 |
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) |
4 |
1 |
3 |
No |
name |
Sets or returns the value of the name attribute of the <img> tag |
4 |
1 |
3 |
Yes |
src |
Sets or returns the URL of the image |
4 |
1 |
3 |
Yes |
useMap |
Sets or returns a URL (often with a bookmark extension - #name) to use as a client-side image map |
5 |
1 |
6 |
Yes |
vspace |
Sets or returns the value of the vspace attribute of the <img> tag in pixels |
4 |
1 |
3 |
Yes |
width |
Sets or returns the value of the width attribute of the <img> tag in pixels |
4 |
1 |
3 |
Yes |
Javascript Image Object Methods
Method |
Description |
IE |
F |
N |
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 |
Javascript Image Object Events
Syntax: object.event_name="someJavaScriptCode"
Event |
Description |
IE |
F |
N |
W3C |
onAbort |
Executes some code when a user aborts the download of an image |
4 |
1 |
3 |
|
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 |
4 |
1 |
3 |
|
onFocus |
Executes some code when the image gets focus |
4 |
|
|
|
onLoad |
Executes some code when the image loads |
4 |
1 |
3 |
|
|