Window -> IFRAME -> DIV
I have a window, that has an iframe, that has a div. The div h开发者_StackOverflowas the ability to scroll the content within but not having full control of the parent window, I have to decide how large the div needs to be from within the iframe.
To do this, I have the following code JavaScript (please pardon the mix of jQuery/straight JavaScript):
$(window.parent).resize(function () {
var frameHeight = parent.document.getElementById('IFRAME_banner').offsetHeight - 52;
$("div.ajax__tab_body").height(frameHeight);
});
This code works fine as long as you resize the window by dragging one of the corners. If you vertically resize by dragging the bottom of the window, it does not fire this event and the div does not properly resize.
I use the iframe as a reference since it seems to automagically resize itself because of something the parent window does. (This is all in MS CRM Dyanamics...so who knows what is happening behind the scenes)
Does anyone know why this would be? And what I would have to do to work around this?
Hackish is ok in this instance. The whole thing is a big hack.
Hack answer: You could create a timer that fires once every second or so and checks the dimensions. If they aren't what you expect, call the event function manually.
The resize event fires differently on different browsers. FF fires repeatedly and IE fires only after the resize is complete. You can't count on it. Use a timer and poll the current size.
精彩评论