HOWTO: Show Web Page Source from a HyperlinkID: Q188762
|
This article describes how to create a hyperlink on a Web page that shows the source code for the current page or another page when the hyperlink is selected.
Using an anchor tag with its associated HREF parameter, you can cause a
hyperlink to display the source of a Web page when the hyperlink is
clicked. To do so, set the value of the HREF parameter equal to "view-
source:someFile.htm" where someFile.htm is the name of an HTML file that
you want to show using the default editor for HTML source code.
Being able to display the source code of a Web page is valuable to those
Internet Content Providers (ICPs) that wish to demonstrate how their pages
have been created.
Please note that "view-source" works only on absolute links. Also, if you
are trying to access an HTML file through the FILE protocol, you must fully
qualify the URL like this:
Some LinkThe following HTML code demonstrates how to show the source code for http://www.microsoft.com/ie40.htm when the hyperlink is pressed.
<HTML>
<HEAD>
<TITLE>Show microsoft.com source code</TITLE>
</HEAD>
<BODY>
<A HREF="view-source:http://www.microsoft.com/ie40.htm">
Show microsoft.com/ie40.htm source code
</A>
</BODY>
</HTML>
NOTE: When you use this protocol a copy of the file is written to the temp directory.
For more information, please see the MSDN Web Workshop:
http://msdn.microsoft.com/workshop/default.asp
Additional query words: kbDHTML kbHTMLObj kbIE400 kbIE401 kbIEObj kbInternet kbSDKInet400 kbSDKInet401
Keywords : kbIE500 kbDSupport
Version : WINDOWS:4.0,4.01,4.01 SP1,5.0,5.0dp1
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: July 22, 1999