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!



