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
精彩评论