0

This might be one of the more daft questions to ask,

but since

<iframe src="view-source:https://ry3yr.github.io/OSTR/Diarykeepers_Homepage/Daymusic.html" width="800" height="600"></iframe>

doesn't work:

Is it possible to display a page's source inside an iframe? (Or any other way really ??)

CLARIFICATION: I know about the browsers built in "view source" function. I want the page source being rendered without user interaction.

Rye
  • 49
  • 5

1 Answers1

1

You could use javascript to fetch the page in question and escape the html.

As an example try using JQuery:


$.get('https://ry3yr.github.io/OSTR/Diarykeepers_Homepage/Daymusic.html', function(data) { 
            var x = document.createElement("pre");
            x.id = "test"
            $("body").append(x); 
            $("#test").text(data);
    });

Or another example with iframe

Roeften
  • 416
  • 3
  • 7
  • Hmm, interesting. Can you show me how to make your example work with an simple iframe ? (Jsfiddle is not my cup of tea. Codepen is far more transparent ..) – Rye Feb 15 '22 at 23:02
  • @Rye I have added an example on Codepen, the idea is the same, escape the html and add it to an element. I do not think you can make an iframe load the source and not render it without a solution like this. – Roeften Feb 15 '22 at 23:31
  • K. Thats good enough. Meanwhile I also found this. Options are always good. Thanks ! https://stackoverflow.com/questions/41945094/add-option-to-view-source-of-current-html-page – Rye Feb 15 '22 at 23:35