Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Image object

Creates and initializes a new img element.


The Image object has these types of members:


The Image object has these methods.


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.


Use this object to instantiate new img elements before adding them to the document. You can specify up to two optional arguments:

nWidthOptional. Integer that specifies the img width.
nHeightOptional. Integer that specifies the img height.


String values are coerced into their numeric equivalents, if possible.


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 );

See also




© 2015 Microsoft