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

123
Views
Mutation observer on iframe is not fired when used as target in a form for php output

Mutation observer on iframe is not fired when used as target in a form for php output.

When change is made from within the java script with

targetNode.innerHTML = 'xxx';

the observer fires.

When the output of a php file is displayed by the form in the iframe, nothing happens.

What am I doing wrong ?

Here is thet HTML/JavaScript

<!DOCTYPE html>
<html>
    <head>
        <title>Mutation Test</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <form action="dummy.php" target='iframe'>
            <input type='submit'>
        </form>
        <iframe name='iframe'></iframe>
        <script >
            targetNode = document.querySelector('IFRAME').contentDocument.body;
            config = {childList: true, subtree: true, attributes: true};
            callback = function (mutationsList, observer) {
                alert('mutation');
            };
            observer = new MutationObserver(callback);
            observer.observe(targetNode, config);

            //targetNode.innerHTML = 'xxx'; //<= this will trigger a mutaion !!!!!!!!!!!!!

        </script>
    </body>
</html>

Here is the php file used as the action for the form

<?php
echo "dummy.php";
about 4 years ago · Santiago Trujillo
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!