开发者

Traverse from element within iframe to parent iframe TAG

I have multiple iframes on the page and need to access the parent Iframe element from the iframe's html element, in 开发者_Python百科order to get the Iframes's height.

So from this:

var htmlElement = $('iframe').contents().find('html');

The following won't work:

var iframeHeight = htmlElement.parents('iframe').attr('height');

Can anyone help please?


Pardon, edit (based on How to access parent Iframe from javascript)

var iframe = null;
parent.$("iframe").each(function(iel, el) {
  if(el.contentWindow === window)
      iframe = el;
});
if (iframe)
    iframe.height()

This needs that the parent window (the one having an iframe) has jQuery

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜