javascript - get all frames from within Iframecheck whether iframes content has frames - Stack Overflow

I have a page which dynamically loads pages into an iframe. I found scripts on the web, which adjust t

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
Add a ment  | 

1 Answer 1

Reset to default 3

you 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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745324047a4622574.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信