I tried using <a href="view-source:google.com">External Source</a>
but that just returns a broken link.
If you're just going to need the HTML source of a webpage, and not anything else, and you're willing to use a server-side language, there is the option of using curl
, file_get_contents
, or Simple HTML DOM to get the HTML of a website, and then display that on your own page between <code></code>
or <pre></pre>
tags. This would look something like this in PHP
include("simplehtmldom.php");
$html=file_get_html($url);
echo "<pre>$html</pre>;
Obviously this should be formatted or prettyprinted. Take a look at Google Code prettifier to do this. If you want to get the source of your own page, you could use Javascript, and do this:
var html=document.documentElement.outerHTML;
I'm not sure how that would work for fetching external pages, but you could try an iframe
for that, like this
document.getElementById('frame').contentWindow.documentElement.outerHTML;