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>