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

152
Views
Why is iframe source code than the source code of file?

I want to load a file into an iframe, then save it out to a file. Right now, just trying in javascript, but would prefer to use Blazor. Maybe it has newer ways to do it?

Anyway, the source code seems to change a little from the file, but I don't want this as I want to save it out exactly the same as the source. For example, here is some code in the file being loaded into the frame:

<!DOCTYPE html>
<!--[if lt IE 9]>
<html class="no-js lt-ie9" lang="en" dir="ltr">
<![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en" dir="ltr">
<!--<![endif]-->
<html>

<head>

...and if I load the outerHTML into a textarea to see what would be saved, it is just:

<html><head>

So ya, any way to get the source from the iframe exactly how it is in the source file? By the way, here is how I currently get the source from the frame into the textarea:

<a href="#" onclick="getIframeContent('myI');">
    Get the content of Iframe
</a>

<br />

<textarea id="txtarea" style="width:100%;height:300px"></textarea>
<br>

<iframe id="myI" src="myPage.html" style="width: 100%; height: 100vh;"></iframe>

    <script>
        function getIframeContent(myI) {
            var frameObj = document.getElementById(myI);
            var frameContent = frameObj.contentWindow.document.documentElement.outerHTML;
            txtarea.value = frameContent;
        }
    </script>
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!