Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
Android WebView : MutationObserver doesn't detect IFRAME being added to html document

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!