Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda