Jump to Real's How-to Main page

Make a link to see the source of a page

See this
<html>
<head>
<title>view-source demo</title>
</head>

<body>
<a href="view-source:http://www.rgagnon.com/examples/viewsource.htm">
  view my source</a>
</body>
</html>
You have to specify the full "path", relative url won't work with the view-source protocol.

With some Javascript, you can bypass this limitation if the "full" path is not known.

<a href="example1.htm" onclick="location.href = 'view-source:' 
  + this.href; return false">example1.htm</a>
Try it here

Thanks to John Taylor-Johnston for this tip.


If you find this article useful, consider making a small donation
to show your supportfor this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]