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

143
Views
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
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!