[Greasemonkey] newbie DOM question

Tod Beardsley todb at planb-security.net
Wed Feb 1 10:54:47 EST 2006


Hi list,

I'm trying to define an img object width with a percentage. Sadly, I
can't seem to get the % expression right.

This doesn't work:

var ImgData = 'data:image/gif;base64,data:image/png;base64,iVBORw0KGgoAAAA...[etc]';
var Img = document.createElement('img');
Img.src = ImgData;
Img.width = '90%'; So this doesn't work.
newDiv.appendChild(Img);

This does:
var ImgData = 'data:image/gif;base64,data:image/png;base64,iVBORw0KGgoAAAA...[etc]';
newDiv.innerHTML = "<img src="+ImgData+" width='90%' />";

Any ideas why? I can use Img.width='100'; fine (makes it 100 pixels),
just the percent makes it all go away.

Thanks!

--
Tod Beardsley | ICQ: 335082155 | www.planb-security.net
Due to Google's privacy policy <http://tinyurl.com/5xbtl>, please
do not IM/e-mail me anything you don't want to be read in court.


More information about the Greasemonkey mailing list