Getting the height of a frame in javascript
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 le开发者_如何学Pythonast 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?
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;
}
精彩评论