3 out of 4 rated this helpful - Rate this topic

Image object

[This documentation is preliminary and is subject to change.]

Creates and initializes a new img element.

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:

nWidthOptional. Integer that specifies the img width.
nHeightOptional. 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

src

 

 

Build date: 3/8/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Mistake in text
The text describing the optional arguments for this constructor makes reference to both "option text" and "option value," and were obviously copied from the docs on the Option object. These should be "image width" and "image height" respectfully.