External Source , but that just returns a broke...">

Can I link the view-source: of an external page?

I tried using <a href="view-source:google.com">External Source</a> , but that just returns a broken link.

+6
source share
3 answers

Missing scheme / protocol http: ::

  <a href="view-source: http: google.com"> External Source </a> `

Test with scURIple (scriple):

 data:text/html;charset=utf-8,<html><a href="view-source:http:google.com">External Source</a></html> 
0
source

If you need the HTML source of the web page, and not something else, and you are ready to use the server language, you can use curl , file_get_contents , or the Simple HTML DOM to get the HTML site and then display it on your page between <code></code> or <pre></pre> tags. It 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 beautiful. Check out the Google Code Prefer to do this. If you want to get the source of your own page, you can use Javascript and do this:

 var html=document.documentElement.outerHTML; 

I'm not sure how this works for fetching external pages, but you can try an iframe for this, like this

 document.getElementById('frame').contentWindow.documentElement.outerHTML; 
+3
source

As an alternative to displaying everything in the <pre> block, consider returning a different type of content. In the response headers:

 Content-Type: text/plain 

Then you can simply return the HTML content and it will display as plain text in the browser.

0
source

All Articles