You can get the nodes of the document
object of an <iframe>
with the contentDocument
property of the HTMLIFrameElement
But I can't find a way getting the <iframe>
back out of the node.
Is the relation between the <iframe>
and it's document is only one way?
If it does, WHY?
var iframe = document.getElementById('iframe');
var doc = iframe.contentDocument || iframe.contentWindow.document;
var div = doc.getElementsByTagName('div')[0];
console.log('Did we find the iframe? ' + ($(div).closest('iframe').length > 0));
// Output: "Did we find the iframe? false"