views:

35

answers:

1

I'm currently working in a system with a bit of a legacy presentation layer -- it uses frames (actual, in a frameset frames).

To get some event handling up and running I would like to get events when the frame resizes or at least be able to measure the height of the frame somehow. There seems to be no cross browser way to do this. Has anyone tried anything like this?

+2  A: 

Try this - Also you might have to try this on all browsers too -

<!-- 
     Example File From "JavaScript and DHTML Cookbook"
     Published by O'Reilly & Associates
     Copyright 2003 Danny Goodman
-->


function getFrameSize(frameID) {
    var result = {height:0, width:0};
    if (document.getElementById) {
        var frame = parent.document.getElementById(frameID);
        if (frame.scrollWidth) {
            result.height = frame.scrollHeight;
            result.width = frame.scrollWidth;
        }
    }
    return result;
}
Sachin Shanbhag
I'd have tried offsetHeight (and ~width) but I'm not sure that works for frames as well. I think this answer will be the right one.
Litso
Yes, thank you, that did work. I was trying to read the cols of the frameset, which didn't work on Webkit. Thank you again!
Marcus