开发者

Traverse from element within iframe to parent iframe TAG

开发者 https://www.devze.com 2023-04-13 00:40 出处:网络
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.

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

精彩评论

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