T
Tim Streater
There are some elements in one of my app's pages whose height values I'd
like to get as soon as possible, since I want to use the values to
calculate and set heights of other elements. And I'd like to be able to
either get the element's natural height or one I set using CSS.
So, I'm doing something like [1]:
h =
document.defaultView.getComputedStyle(e,null).getPropertyValue("height");
where e is a pointer to my element.
But I find that if I do this right at the start of the onload function,
I get back a zero value, whereas if I do it a bit later (e.g. after
waiting for some ajax calls to complete), then I get the proper value.
So when are these style values set? The reason for this is to avoid what
I do at the moment: compute the true height by hand and just have a
JavaScript variable initialised to that value.
[1] If/when I can sort this I can collect the border/margin/padding
values too.
like to get as soon as possible, since I want to use the values to
calculate and set heights of other elements. And I'd like to be able to
either get the element's natural height or one I set using CSS.
So, I'm doing something like [1]:
h =
document.defaultView.getComputedStyle(e,null).getPropertyValue("height");
where e is a pointer to my element.
But I find that if I do this right at the start of the onload function,
I get back a zero value, whereas if I do it a bit later (e.g. after
waiting for some ajax calls to complete), then I get the proper value.
So when are these style values set? The reason for this is to avoid what
I do at the moment: compute the true height by hand and just have a
JavaScript variable initialised to that value.
[1] If/when I can sort this I can collect the border/margin/padding
values too.