Unable to inspect iframe with same origin
rsvaldes-amplifire opened this issue · 3 comments
Hi, I'm trying to use dom-inspector to inspect elements within an iframe that has the same origin. I've confirmed that I have access to this iframe using the following code, passing in the iframe element:
function canAccessIFrame(iframe) {
var html = null;
try {
// deal with older browsers
var doc = iframe.contentDocument || iframe.contentWindow.document;
html = doc.body.innerHTML;
} catch(err){
// do nothing
}
return(html !== null);
}
I'm able to see the dom-inspector object in the dev tools and it has the iframe I am expecting as its "root"property, but there is no highlighting happening.
The minified js file is hosted and loaded via a script tag on the parent page.
Post the calling code, maybe its a call error
Thanks for the reply. Here's the calling code:
var inspector = new DomInspector({
root: '#kfIframePreview',
maxZIndex: '',
});
inspector.enable();
I've also tried passing in for the root:
root: '#kfIframePreviewWrapper ', // div that is direct parent to iframe
root: document.getElementById("kfIframePreview").contentWindow.document.querySelector('body')
It seems that I had to load a script tag for the dom-inspector.min.js file in the iframe as well as the parent page. It's working now!