Image object (Object/HTML)

An object representing an HTML <IMG> tag in Netscape.

Availability:

DOM level - 1
JavaScript - 1.1
Netscape - 3.0
Opera - 3.0
Inherits from:Element object&
JavaScript syntax:IEmyImage = myDocument.all.anElementID
IEmyImage = myDocument.all.tags("IMG")[anIndex]
IEmyImage = myDocument.all[aName]
-myImage = myDocument.anImageName
-myImage = myDocument.getElementById(anElementID)
-myImage = myDocument.getElementsByName(aName)[anIndex]
-myImage = myDocument.images[anIndex]
-myImage = myImageArray[anIndex]
-myImage = myDocument.getElementsByTagName("IMG")[anIndex]
HTML syntax:<IMG>
Argument list:anIndexA reference to an element in a collection
aNameAn associative array reference
anElementIDThe ID value of an Element object
Object properties:border, complete, constructor, defaultValue, height, hspace, lowsrc, name, size, src, vspace, width, x, y
Object methods:select()
Event handlers:onAbort, onBlur, onClick, onDblClick, onError, onFocus, onHelp, onKeyDown, onKeyPress, onKeyUp, onLoad, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp

The Image object added at version 1.1 of JavaScript introduced the possibility of dynamically replacing images under script control.

Event handling support via properties containing function objects was added to Image objects at version 1.1 of JavaScript.

The Image object supported by Netscape and the IMG object supported by MSIE are so different to each other that they are covered as separate objects. They share a few similarities but not many. By inspection, they are instances of different classes.

Warnings:

Example code:

   <HTML>
   <HEAD>
   <SCRIPT>
   function moved()
   {
      document.all.ONE.width = event.x;
   }
   </SCRIPT>
   	
   </HEAD>
   <BODY onMouseMove="moved()">
   Move mouse horizontally to scale image<BR>
   <IMG HEIGHT=40 ID="ONE" SRC="assets/image_9.gif">
   
   </BODY>
   </HTML>

See also:Background object, Document.images[], Element.all[], ImageArray object, IMG object, Input object, Input.type, Web browser

PropertyJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
border1.1 1.1 n/a3.0 3.0 n/a3.0 3.0 n/a n/a1 1 n/a n/a-
complete1.1 1.1 n/a3.0 3.0 n/a3.0 3.0 n/a n/a n/a n/a n/aWarning , ReadOnly.
constructor1.1 1.1 n/a3.0 3.0 n/a n/a n/a n/a n/a n/a n/a-
defaultValue1.1 1.1 n/a3.0 3.0 n/a3.0 3.0 n/a n/a1 1 n/a n/aWarning
height1.1 1.1 n/a3.0 3.0 n/a3.0 3.0 n/a n/a1 1 n/a n/aReadOnly.
hspace1.1 1.1 n/a3.0 3.0 n/a3.0 3.0 n/a n/a1 1 n/a n/aReadOnly.
lowsrc1.1 1.1 n/a3.0 3.0 n/a3.0 3.0 n/a n/a1 1 n/a n/a-
name1.1 1.1 n/a3.0 3.0 n/a3.0 3.0 n/a n/a1 1 n/a n/a-
size1.1 1.1 n/a3.0 3.0 n/a3.0 3.0 n/a n/a1 1 n/a n/aWarning
src1.1 1.1 n/a3.0 3.0 n/a3.0 3.0 n/a n/a1 1 n/a n/a-
vspace1.1 1.1 n/a3.0 3.0 n/a3.0 3.0 n/a n/a1 1 n/a n/aReadOnly.
width1.1 1.1 n/a3.0 3.0 n/a3.0 3.0 n/a n/a1 1 n/a n/aReadOnly.
x1.1 1.1 n/a3.0 3.0 n/a n/a n/a n/a n/a n/a n/aReadOnly.
y1.1 1.1 n/a3.0 3.0 n/a n/a n/a n/a n/a n/a n/aReadOnly.

MethodJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
select()1.1 1.1 n/a3.0 3.0 n/a3.0 3.0 n/a n/a1 1 n/a n/aWarning

Event nameJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
onAbort1.1 1.11.0 1.03.0 3.03.02 3.023.0 3.0 n/a n/a n/a n/a n/a-
onBlur1.1 1.13.0 3.03.0 3.04.0 4.03.0 3.0 n/a n/a n/a n/a n/aWarning
onClick1.11.11.0 1.02.0 2.03.0 3.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onDblClick1.2 1.23.0 3.04.0 4.04.0 4.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onError1.1 1.13.0 3.03.0 3.04.0 4.03.0 3.0 n/a n/a n/a n/a n/aWarning
onFocus1.11.13.0 3.02.0 2.04.0 4.03.0 3.0 n/a n/a n/a n/a n/aWarning
onHelp n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/aWarning
onKeyDown1.2 1.23.0 3.04.0 4.04.0 4.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onKeyPress1.2 1.23.0 3.04.0 4.04.0 4.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onKeyUp1.2 1.23.0 3.04.0 4.04.0 4.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onLoad1.11.11.0 1.02.0 2.03.02 3.023.0 3.0 n/a n/a n/a n/a n/aWarning
onMouseDown1.2 1.23.0 3.04.0 4.04.0 4.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onMouseMove1.2 1.23.0 3.04.0 4.04.0 4.0 n/a n/a n/a n/a n/a4.0 4.0Warning
onMouseOut1.1 1.13.0 3.03.0 3.04.0 4.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onMouseOver1.11.11.0 1.02.0 2.03.0 3.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onMouseUp1.2 1.23.0 3.04.0 4.04.0 4.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning

Inheritance chain:

Element object, Node object