Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda