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

180
Views
how to get editor output inside a div instead of a iframe

I have made a code editor works well with js html and css. The out put is also given out automatically inside an iframe. but I want this output inside a div because I also want to drag and drop some elements inside the output section. Here's my code

<script type="text/javascript">
function run() {
    let htmlCode = document.querySelector(".editor #html-code").value;
    let cssCode = "<style>" + document.querySelector(".editor #css-code").value + "</style>";
    let jsCode = document.querySelector(".editor #js-code").value;
    let output = document.querySelector(".editor #output");
    // html css runner
    output.contentDocument.body.innerHTML = htmlCode + cssCode;
    // java runner
    output.contentWindow.eval(jsCode);
}
document.querySelector(".editor #html-code").addEventListener("keyup", run);
document.querySelector(".editor #css-code").addEventListener("keyup", run);
document.querySelector(".editor #js-code").addEventListener("keyup", run);

require pure js

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!