In javascript, an image's dimensions are read only. An image tag's dimensions are another matter. The confusion arises due to the unconventional way you have chosen to create an image tag:
Code:
var myImg = new Image() ;
myImg.src = "http://www.cortland.edu/flteach/mm-course/forms1.jpg" ;
myImg.height = 500 ;
myImg.width = 600 ;
document.getElementById('imageTest').appendChild(myImg) ;
This would more accurately be expressed:
Code:
var myImg = document.createElement('img') ;
myImg.src = "http://www.cortland.edu/flteach/mm-course/forms1.jpg" ;
myImg.height = 500 ;
myImg.width = 600 ;
document.getElementById('imageTest').appendChild(myImg) ;
The browser will not know the dimensions of the actual image file until they have been loaded. Regardless of this information, the browser will accept your dimensions (in most cases), scaling the presentation of the image to them. However, the size of the image file itself remains unchanged - hence read only.
Bookmarks