开发者

Can/does Firefox fire a resize event for a div that it sizes the width automatically?

I have a开发者_开发百科 page that only contains a single div like this:

<div style="background-color: blue; height:30px;" onresize="alert('onresize');" ></div>

Per the standard, Firefox will automatically make the div's width equal to the width of its container which in this case is the entire window. But when I resize the browser window, Firefox doesn't fire a resize event on this div. I tested in IE and it does. I would say that Firefox is resizing the div's width because no scroll bars appear if I make the window smaller but then again when I look at the elements dimensions in Firebug, the width is NOT updated so it seems like mixed messages.

My main goal is to have a cross-browser event handler for the resize event on this div but I'd like to avoid using jQuery for now. Possible?


I have never tried to hook into a Div's resize event, not sure if or how to make that work.

What I have made work before on both IE and FF is to hook into the window resize event and then adjust div size based on the new window size. Usually I am trying to get a left side menu to fill the screen vertically or force a content div to fill in the remainder of the screen after a top header and/or left menu have been rendered. Not sure what you are trying to accomplish but this might be another approach to take.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜