MozillaZine

Getting properties width, height dynamically generated image

Discussion of bugs in Seamonkey
mw22
 
Posts: 2379
Joined: November 19th, 2002, 5:37 pm

Post Posted December 11th, 2002, 6:51 am

Hi there,
Testcase:
http://home.hccnet.nl/m.wargers/test/mo ... mgtest.htm
Clicking on the link and an image will be created.
When you look at the statusbar, you can see the (offset)width and (offset)height properties of the (first) image just before and after appendchild.
I can imagine that these properties aren't available before appendchild (however I think it's possible in IE to use them), but after appendchild, these properties should be assigned by the browser I think.
Am I wrong here? Or is there already a bug report?

Thanks and regards, Martijn

laszlo

User avatar
 
Posts: 5203
Joined: November 4th, 2002, 6:13 pm
Location: .de

Post Posted December 11th, 2002, 10:19 am

If I'm not mistaken, .offsetWidth and .offsetHeight are properties of Microsoft's all object. It's not very likely that they're going to work in Mozilla as expected.

mw22
 
Posts: 2379
Joined: November 19th, 2002, 5:37 pm

Post Posted December 12th, 2002, 10:13 am

If I use the getcomputedstyle version to detect the width and height of the image, I get the same values as offsetwidth and offsetheight.
The first time I get wrong values 24 and 24, but after I refresh and then click another time I get the correct values 75 and 56.
The problem for me is: There doesn't seem to be a way to get the width and height of the image without setting it by myself.

WillyWonka

User avatar
 
Posts: 212
Joined: November 5th, 2002, 12:25 pm
Location: Toronto

Post Posted December 12th, 2002, 1:50 pm

This is a bookmarklet that I use (It zooms all the images on a page). It might help.
<code>
javascript:(function(){
function zoomImage(image, amt) {
if(image.initialHeight == null) {
/* avoid losing height information due to
integer rounding while zooming out */
image.initialHeight = image.height;
image.initialWidth = image.width;
image.scalingFactor = 1;
}
image.scalingFactor *= amt;
image.width = image.scalingFactor * image.initialWidth;
image.height = image.scalingFactor * image.initialHeight;
}
for (i=0; i<document.images.length; ++i)
zoomImage(document.images[i], 2); })();
</code>

mw22
 
Posts: 2379
Joined: November 19th, 2002, 5:37 pm

Post Posted December 13th, 2002, 7:11 am

Thanks for your reply WillyWonka. I've used your case to make another (messy) testcase:
http://home.hccnet.nl/m.wargers/test/mo ... gtest2.htm
I see now what the problem is. The image attributes are not available at runtime. If I set a timeout('function()',0) then I don't have that problem.
I find this a bit weird. Shouldn't image width and height attibutes be available at runtime?

Return to SeaMonkey Bugs


Who is online

Users browsing this forum: No registered users and 2 guests