Microsoft Corporation
Updated: May 12, 1999
If you've built help projects using HTML Help, you probably know that you can link to a Web page from a topic in a compiled help (.chm) file. This is a great way to give users access to updated material. But what if you want to link to a specific help topic in a .chm from a Web page? This can easily be done by defining a new window type in your help project, and using the showHelp method to call HTML Help and display the topic.
To link to a topic in a .chm file from a Web page
mk:@MSITStore:C:\Program Files\My Program\help\myhelp.chm::/mytopic.htm>mywindowThe first part of the string uses the moniker protocol:
>mk:@MSITStore:Next comes the path to the compiled help file location on the user's machine. Relative paths do not work. Use backslashes. For example:
C:\Program Files\MyProgram\help\myhelp.chmAfter this path, add two colons and a forward slash:
::/Then you must add the file name of the HTML file you want to appear. If you need to specify a path within the CHM, be sure to use forward slashes for this path. If the file is in a subdirectory of the compiled CHM file, add that too:
mytopic.htmor
mysubdir/mytopic.htmFinally, you must add a ">" bracket and the the window type name:
>mywindowHere is a sample Web page that shows one way of implementing the showHelp method:
<HTML> <head><title>Test of HTML Help</title></head> <body> <script language="VBScript" EVENT="OnClick" FOR="link_1"><!-- window.showHelp( "mk:@MSITStore:C:\Program Files\My Program\help\myhelp.chm::/mytopic.htm>mywindow") //--></script> <a name="link_1" HREF="#">Link to mytopic.htm</a> </body> </HTML>
Although this example adequately demonstrates the functionality of the showHelp method, it has a shortcoming: each link requires its own script. That means if you have five links on a page, you also need to duplicate the script five times. To get around this, try passing the path as a variable as shown in the following example:
<script language="VBScript"> sub link_all(url) window.ShowHelp("mk:@MSITStore:"+url+">mywindow") end sub </script>
Use the following syntax for each link:
<a href="#" onclick='link_all("C:\my documents\test\testproj1.chm::/file1.htm")'>file 1</a> <a href="#" onclick='link_all("C:\my documents\test\testproj1.chm::/file2.htm")'>file 2</a>Note You can also use a standard <A HREF> link to open an entire help file from a Web page. When a user clicks the link a dialog box will appear that gives them the option of saving the compiled help file to their hard disk or opening it from the directory where it's located. For example,
<A HREF="file name.chm">Link text</a>.
Tips and Tricks |