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

142
Visualizações
Why can't I access the contentWindow of an Iframe

Why can't I access the contentWindow of an iframe?! I am trying to create something like https://jsbin.com with it's functionality, but I am unable to access the contentWindow of the iframe for me to run my js in it. I can use eval to run my javascript string... But I'm unable to run it inside the iframe, therefore I suspect I am unable to access the contentWindow of the iframe. Please enlighten me, Thank you in advance. Here is my code:

<html>

    <head>
    
        <title>JS Bin Clone</title>

    </head>

    <body>
    
        <div id="javascript" class="code-container">
    
            <textarea name="javascript" id="javascriptTextArea"></textarea>
            
        </div>

        <div id="output"  class="code-container">

             <iframe id="output-iframe"></iframe>
              
         </div>
         
         <script type='text/javascript'>
         
             function updateOutput() {

                 var js = document.getElementById('javascriptTextArea').value;
                
                 document.getElementById('output-iframe').contentWindow.eval(js);

             }

             updateOutput();
         
         </script>
    
    </body>

</html>

PS: (I am using eval()).

about 4 years ago · Juan Pablo Isaza
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