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

220
Views
How to feed code into iframe without a URL or FILE?

I'm trying to create a visual editor where the user creates a 3D scene, and my application writes the code for the project itself. I want to create a testing feature where the code that was generated is run. I've looked into using iframes, but as far as I know, you need a specific URL for iframe.

Here are some ideas/solutions I've come up with:

  • Is there a way to manually feed code to an iframe, without a file or URL?
  • Is there any other easier way to accomplish this task?
  • Can this be done without server side code?

Let me know if you need any more information. Thanks!

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

0

Yes it is possible however a much simpler way would be to just create another html file somewhere on your server/host and just disallow external access to it so it's only accessible from the iframe.

You have to use an script to give code to an iframe without a source file like this:

<iframe id="my-iframe"></iframe>

<script>
document.getElementById("my-iframe").contentDocument.write("<h1>Hello World</h1>");
</script>

Change the JavaScript to this to overwrite all of the content of the iframe:

var iframe = document.getElementById("my-iframe");
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;

iframeDocument.body.innerHTML = "<h1>Goodbye World</h1>";

This overwrites all the content of the iframe with your own.

This will work but it will be a big pain to format the html from the iframe. Also as far as I know this is the simplest way that fits your needs.

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!