开发者

IE9 and IE8 loading image set a width

开发者 https://www.devze.com 2023-03-20 05:00 出处:网络
var img_src=\"/xxx.jpg\"; var img = new Image(); img.src = img_src; //img.height=height; img.width=200;
var img_src="/xxx.jpg";
var img = new Image();
img.src = img_src;
 //img.height=height;
 img.width=200;
 img.removeAttribute('heigh开发者_JAVA百科t');

The Image is loading with default size in IE8 and IE9 and i have checked it in google chrome and firefox it is working fine.


Width or Height have to be set with units like:

img.width = "200px";


I suspect IE overwrites the width and height attributes when the image loads. To work around the problem, use img.style.width = "200px"; img.style.height = "auto";.

0

精彩评论

暂无评论...
验证码 换一张
取 消