Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How To Show Web Page Source from a Hyperlink


View products that this article applies to.

This article was previously published under Q188762

↑ Back to the top


Summary

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.

↑ Back to the top


More information

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 Link
The 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.

↑ Back to the top


References

For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:

↑ Back to the top


Keywords: KB188762, kbieobj, kbhtmlobj, kbhowto, kbdhtml

↑ Back to the top

Article Info
Article ID : 188762
Revision : 3
Created on : 5/11/2006
Published on : 5/11/2006
Exists online : False
Views : 390