Image Element constructor
Accepts two optional parameters: Image([unsigned long width, unsigned long height])
Example:
var myImage = new Image(100, 200); myImage.src = '/old?u=https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FAPI%2FHTMLImageElement%2Fpicture.jpg&y=1999'; console.log(myImage);
Result:
<img width="100" height="200" src="/old?u=https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FAPI%2FHTMLImageElement%2Fpicture.jpg&y=1999">
Note: this constructor exists for historical reasons and returns an HTMLImageElement instance just as document.createElement('img') would.
| Specification | Status | Comment |
|---|---|---|
| HTML5 The definition of the Image constructor in that specification. |
Candidate Recommendation | A constructor (with 2 optional parameters) has been added. The following properties are now obsolete: name, border, align, hspace, vspace, and longdesc.The following properties are now unsigned long, instead of long: height, and width.The following properties have been added: crossorigin, |