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

90
Views
JavaScript: How to Writeln "</script>" without ending the actual script

I am making a code editor similar to Codepen, however when I try to make my Javascript textarea to say </script>, it will think I want to end the script of the actual program.

<script>
    function compile() {
      var html = document.getElementById("html");
      var css = document.getElementById("css");
      var js = document.getElementById("js");
      var code = document.getElementById("code").contentWindow.document;

          submit = () => {
              code.open();
              code.writeln(
              html.value +
                  "<style>" +
                  css.value +
                  "</style>" +
                  "<script>" +
                  js.value +
                  "</script>"
              );
              code.close();
          };
      }
      compile();
  </script>

I understand this could be easily fixed by instead making this a separate .js file, but I want to know how to put this script in an HTML file without it thinking "" is to end the actual html files script.

Thank you in advance

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!