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

151
Vistas
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 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