Image object
Creates and initializes a new img element.
Members
The Image object has these types of members:
Methods
The Image object has these methods.
| Method | Description |
|---|---|
| create |
Creates a new img element of the specified width and height. This method cannot be called directly. See Image object. |
Standards information
There are no standards that apply here.
Remarks
Use this object to instantiate new img elements before adding them to the document. You can specify up to two optional arguments:
| nWidth | Optional. Integer that specifies the img width. |
| nHeight | Optional. Integer that specifies the img height. |
String values are coerced into their numeric equivalents, if possible.
Examples
The following script creates a new image and appends it to the body object..
<script type="text/javascript"> var img = new Image(50, 50); img.src = "image.png"; document.body.appendChild( img ); </script>
See also
Show: