I have a page which dynamically loads pages into an iframe.
I found scripts on the web, which adjust the height of the iframe depending on the height of it's content.
But it does not work if the content page hast (normal)frames itself.
Now I want to check, whether the content page has frames or not, or even better access them so that I can calculate their lenght and then choose the highest length value from the subframes to be to length of my iframe.
Please help without JQuery. Just plain old Javascript. :-)
Thanks
I have a page which dynamically loads pages into an iframe.
I found scripts on the web, which adjust the height of the iframe depending on the height of it's content.
But it does not work if the content page hast (normal)frames itself.
Now I want to check, whether the content page has frames or not, or even better access them so that I can calculate their lenght and then choose the highest length value from the subframes to be to length of my iframe.
Please help without JQuery. Just plain old Javascript. :-)
Thanks
Share Improve this question asked Oct 12, 2012 at 21:16 DenderDender 1651 silver badge7 bronze badges 2- 7 @BradGilbert why must i use it? sometime is overkilling use a framework only for a function – user757095 Commented Oct 12, 2012 at 21:29
- If you say you can't use something, the reason should be in the question. Also as far as I know JQuery is "Just plain old Javascript" with a good API. – Brad Gilbert Commented Oct 12, 2012 at 21:40
1 Answer
Reset to default 3you can access the frames property of the window object. it's an array containing all the frames in the current document.
// suppose a max of 1 frame each inner frame
function getInnerFrame(win) {
win = win || window;
if (win.frames.length > 0)
return getInnerFrame(win.frames[0]);
else
return win;
}
EDIT: corrected a very stupid error