I had the same problem when I build the Slideshow plugin. Images don't
have width and height in computed styles so to get the right dimensions
use:
/**
* Calculates the height of every image in the selection.
*
Necesary for vertical justifying purposes.
*
Has to be called before verJustify().
*
@see verJustify()
*
@example calHeight("#left");
* @param string query - The selection to be precalculated
*
@return none
*/
function calHeight(query){
query = query + "
img";
$(query).each(function(){
$(this).css("height", this.height + 'px');
});
}
Abel Tamayo wrote:
Ok. I give Up. I need to
know the height of certain images in my page to be able to format it
and I've tried several workarounds like this function that I call right
before my verJustify() function (yeah, a function that lets me justify
vertically all divs in my page, just like the plug in):
/**
*
Calculates the height of every image in the selection.
*
Necesary for vertical justifying purposes.
*
Has to be called before verJustify().
*
@see verJustify()
*
@example calHeight("#left");
*
@param string query - The selection to be precalculated
*
@return none
*/
function calHeight(query){
query = query +
" img";
$(query).each(function(){
$(this).css("height", $(this).css("height"));
});
}
The problem with my layout is that basically every image's size is set
dinamically when the page loads. Like a liquid layout but instead of
using CSS and text, with a lot of images and _javascript_.
My theory was: ok, if Firefox doesn't calculate the width of an image
before the formatting of the page, maybe i can force it to do it.
It works for some things but not for others and I don't know what else
to try. The funny thing is that, in debugging mode, if I set a
breakpoint to this function and then just let it execute, it works
perfectly, but if I don't pause it manually it seems like there's not
enough time to calculate every image's height.
¿Any suggestions?
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
|
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/