I'm writing an app the contains a WebView in which I display pages from different websites. Some of these pages contain IFrames.
My app injects javascript into the displayed WebView and my problem is that my MutationObserver code seems to miss the addition of new Iframes in the DOM.
My code is pretty generic, taken from from detect-load-of-iframe-not-same-domain-dynamically-added-in-javascript-or-jque (which reportedly works):
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
[].filter.call(mutation.addedNodes, function (node) {
return node.nodeName == 'IFRAME';
}).forEach(function (node) {
node.addEventListener('load', function (e) {
console.log('loaded', node.src);
});
});
});
});
observer.observe(document, { childList: true, subtree: true });
I'm not interested in what's going inside the Iframe , so cross-origin content is of no concern here. I'm only interested in retrieving the Iframe's 'src' attribute.
Any ideas on how to intercept the Iframe's creation?
Edit : I cannot load additional javascript files, I need to use only native javascript code for this.
thanks
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment