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

330
Views
MutationObserver on iFrame Content suddenly TypeError: parameter 1 is not of type 'Node'

I embedded an iFrame on my website and the iFrame comes from the same domain as the website. I observed the content within the iFrame if it will change and then do something as reaction. I coded it like 8 months ago or so and suddenly it isn't working anymore. I don't really think I did any updates which could cause the code to not work anymore.

The error message I receive is Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'.

So I googled it and it seems that the jQuery selector isn't working as expected because the content of the iFrame isn't fully loaded I think.

Here is my code:

$(document).ready(function() {
    $('iframe').on('load', function() {
        checkIframeLoaded();
                
        function checkIframeLoaded() {
            var iframe = document.getElementById('test');
            var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
                    
            if(iframeDoc.readyState  == 'complete') {   
                //this was original coded
                //observer.observe($('iframe').contents().find('.transition-group').first()[0], {
                observer.observe(iframe.contentWindow.document.getElementsByClassName('transition-group')[0], {
                    childList: true,
                    subtree: true
                });
                        
                return;
            } else {
                window.setInterval(checkIframeLoaded, 1000);
            }
        }
    )};
)};

I added the checkIframeLoaded function after I saw the error, originally there was just the observer. part of the code. Any ideas how I get this working? I believe I have to wait until the content is finished with loading but I think I already coded it.

Edit: When refreshing the browser, sometimes the error message goes away and sometimes not. So I would say it has something to do with the loading process.

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!