Hi!

I have some scripting foo where I add some element dynamically and the
want to query the width of it.

NOTE: The reason I want width is for centering. If anyone knows a way
to center a DIV element without knowing its width, just say so and the
below problem is irrelevant. (same goes for height and vertical
centering)

It is more or less like this:

$(top.document.body).append("<div id='TB_window'></div>");
// inject a LINK element into top.document for a CSS file
then append some stuff into TB_window,
// marker 1
then call  $("#TB_window",top.document).width()


If I put an alert() at "marker 1" before the width() call, I get
different results than without.
It seems Firefox (v3.5.3) takes the opportunity while the alert is
displayed to compute
some stuff, which makes the width() result correct. If I don't use
alert(), then width()
returns s smaller value (about 30% less)  than the real one.

Funny, in IE8 there is no such problem. There the correct width is
reported.

I use JQuery 1.3.2.

I put the entire code at http://pastie.org/658921

it is called from HTML by
a href="#"
onclick="tb_show('#TB_inline?
height=332&amp;width=590&amp;inlineId=lb_content&amp;modal=false',
(this.rel || false),'/stuff/css');return false;"
PopupboxNM /a  (I removed brackets in case they give problems to mail/
web programs)


Regards,
David

Reply via email to