image setAttribute() does not work in IE 8
Internet Explorer / Firefox Issues September 22nd, 2011Blogging after almost 10 months…Whew…long time!
Today I was trying to resolve an issue wherein an image was being displayed dynamically, but it wasn’t visible in it’s proper width & height only in IE 8. The height & width were being set by:
img.setAttribute(”width”,”50px”);
img.setAttribute(”height”,”50px”);
It didn’t take much time to resolve this issue. The issue was that IE 8 (Not sure of other versions) didn’t like the above method of setting the width & height. Instead, I had to use the below:
img.style.width = “50px”;
img.style.height = “50px”;
This worked like a charm in all browsers.
Related posts:





Recent Comments