There are many posts on this topic here, but none are solutions for launching a CHM helpfile from a web page.
Background:
- This project is not on the internet, it is a web site that is run locally on a medical device running in IE11.
- It was previously coded as a Flash ActionScript web app, and successfully used ActionScript's ExternalInterface.call("callJavascript", variableStr ); to open the CHM file. Unfortunately, the project needs to be ported to HTML5, and I've yet to find a JavaScript solution that works.
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:
<script type="text/javascript">
function callJavascript(str) {
//window.alert(str);
window.showHelp(str);
}
</script>
Should be easy to convert to just straight JS - right? I have many problems unfortunately.
- When calling similar function in a straight HTML5 page, I get a 404 error "item not found" when concatenating the full CHM path & page together and passing it to the launch function.
- If I leave the page out and just use the path to the CHM file alone, the browser prompts to "Open or Save" the file. When I choose "Open" the CHM file launches in Microsoft HTML Help Control Version 10.0 to the first page in the stack but only shows the navigation panel of pages, and the body area is blank/empty. Manually selecting a page from the Nav panel opened in this manner will not show its contents in the body area. However, if I open the CHM file manually from the desktop it displays all the pages in the body area, but still fails when launching it from the web page.
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!
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:
The prefix
ms-itsis a pluggable protocol from earlier days that follows old standards set up by the World Wide Web Consortium (W3C). Thems-itsprotocol 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:\_workingfolder. Please notewindow.showHelpopens 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.The button steps (2 and 3) are resulting in a the screenshot below (please note the second browser tab as result of third button).
You may want to download the above used
CHM-example.chmfile 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:
After creating the
test.htmfrom 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.