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

228
Views
iframe: How to display raw (plain text) html?

I want to display an HTML string as raw/plain text HTML in an iframe.

For example, display "<b>Hello World</b>" (instead of Hello World).

I've tried to display it like this:

<iframe srcdoc="<pre><b>Hello World</b></pre>"></iframe>

But it didn't work. It displays bold "Hello world" text.

I'm using Nuxt.js.

What am I missing?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

With no iframe

<pre id="code"></pre>

<script>
  document.getElementById('code').textContent = '<b>Hello World</b>';
</script>

With an iframe

<iframe id="codeFrame"></iframe>

<script>
  function writeToIframe(iframe, markup) {
    iframe.contentWindow.document.open();
    iframe.contentWindow.document.write('<pre id="code"></pre>');
    iframe.contentWindow.document.getElementById('code').textContent = markup;
    iframe.contentWindow.document.close();
  }

  writeToIframe(document.getElementById('codeFrame'), '<b>Hello World</b>');
</script>
about 4 years ago · Juan Pablo Isaza Report
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!