Open CHM help file to a specific page via JavaScript

The path to the CHM file and to each page within it are taken from a JSON file, and depending on which page needs to be accessed in the CHM, the link is concatenated. An example of this is chm/myHelp.chm::cat2page1.html.

So with ActionScript, when the user clicked a button, this function created the full string passed to a JavaScript function named "callJavascript" in the containing HTML page, which in turn opened the CHM file to the correct page:

private function launchURL(e:MouseEvent) < if (_helpLibIndex != "" && _myHelpLink != "") < // ex: JavaScript: callJavascript('chm/GloCyte.chm::cat2page1.html') var variableStr:String = _helpLibIndex + "::" + _myHelpPageLink; ExternalInterface.call("callJavascript", variableStr ); >> 

And the JavaScript on the HTML page hosting the Flash swf:

  

Should be easy to convert to just straight JS - right? I have many problems unfortunately.

Here is my JS code in the new HTML5 page. The _helpLibIndex and _myHelpLink are previously retrieved from the imported JSON file:

function launchURL() < if (_helpLibIndex != "" && _myHelpLink != "") < // appending myHelpLink gives 404 error. // leaving it off kinda launches the CHM, but no content is viewable in the body area // example string = 'chm/myHelp.chm::cat2page1.html' var variableStr = _helpLibIndex + "::" + _myHelpLink; window.showHelp(variableStr); console.log("attempted to launch the showHelp file. URL is: " + variableStr); >

I don't quite understand the difference between ActionScript working in this case, and JavaScript not, since the final call in both cases is JS from the hosting web page. Any help is hugely appreciated!

asked Dec 11, 2020 at 1:14 Kevin Hays Kevin Hays 33 5 5 bronze badges

1 Answer 1

The short story - use full path when looking inside a ITS (CHM) file. Relative path specifications including topic specification within the CHM do not work according to my tests. It only works for the CHM help file itself.

A series of security fixes years ago has reduced HTMLHelp to functioning as local help only. Maybe this has been fixed differently.

I hope to give you an idea, but you'll have to adapt it for your needs (you mentioned using IE11). I have no experience with Flash ActionScript because there has always been a security issue with it as well. So, I don't know why ActionScript is working in this case, and JavaScript not.

HTML Help 1.x does not have the capability of delivering compressed help over http. You can point to a .chm on the user's local drive, and you can link to a .chm for download, but that's as far as it goes.

The ability to look inside an ITS (CHM) file is something unique to Microsoft Internet Explorer only. Only Internet Explorer (NOT Microsoft Edge browser) could load a locally path like:

ms-its:D:\_temp\CHM-example.chm::/garden/garden.htm 

<a href=enter image description here" />

The prefix ms-its is a pluggable protocol from earlier days that follows old standards set up by the World Wide Web Consortium (W3C). The ms-its protocol works with Microsoft Internet Explorer 4.0 or later, but is not supported in all browsers.

So, I have a test.htm file and a CHM-example.chm file in the same local D:\_working folder. Please note window.showHelp opens a HTML help file (.chm) in an external application (Help Viewer hh.exe).

Please make shure to test this using Internet Explorer 11 (context menu, open with IE11). AFAIK - showHelp() isn't a javascript (or JScript) function - it's an Microsoft Internet Explorer DHTML method.

      

Help Information www.help-info.de


Open a help file


Open a help topic


Open a help topic in a new browser tab

The button steps (2 and 3) are resulting in a the screenshot below (please note the second browser tab as result of third button).

<a href=enter image description here" />

You may want to download the above used CHM-example.chm file from my HTMLHelp (HH) info site see download section or download directly from CHM.

Edit: (after comments)

As a first step after saving this CHM file in a local drive: Please check if after double-clicking on the CHM file the content is completely shown in the topic window on the right.

If not please note - to open this CHM file right-click the file, click Properties, and then check Unblock and click OK as shown in the screenshot below:

<a href=enter image description here" />

After creating the test.htm from the code above in the same directory make sure to open with Internet Explorer and to Allow Blocked content.

The message with the button at the bottom of the browser window will disappear automatically after about 10 seconds for security reasons.