I\'m appending the dynamically created image element to document.
var img = new Image();
img.src = \'test.jpg\',
img.onload = function() {
var addedImg = co
var img = new Image();
var container = document.getElementsByTagName("div")[0];
container.appendChild(img);
img.onload = function() {
alert('Width = ' + img.width);
}
img.src = "http://globe-views.com/dcim/dreams/image/image-03.jpg";
div {
width: 200px;
}
img {
display: block;
width: 100%;
height: 100%;
}