JS window.open to open a different Help File in same window

This forum is for all Flare related Tips and Tricks.
Have a tip or trick you use while working in Flare? Share it here.
Post Reply
MC Hammer
Sr. Propeller Head
Posts: 225
Joined: Wed Aug 08, 2007 3:04 am
Location: In a galaxy far, far away

JS window.open to open a different Help File in same window

Post by MC Hammer »

Hi there
I am having a Javascript issue (I know very little in JS) and thought of looking for some help here.
I have several HTML Help Files, each of them for a different product incarnation (ProductA.CHM, ProductB.CHM, etc). These Help Files will all be located in the same folder on the clients' PCs, along with another Help file that is generic and explains how to use the Help Files (I will call this file Generic.CHM).
In my product incarnation CHMs, I have a WebHelp toolbar with a button that, when clicked on, opens Generic.CHM, on the introduction.htm page, but in the same window as ProductA.CHM, ProductB.CHM, etc (i.e. if I have ProductA.CHM open, and if I click on this WebHelp button, I would like to display the introduction.htm page from the Generic.CHM file, but still in the ProductA window).

I have been advised to type the following on the OnClick event of the WebHelp toolbar button:
window.open(ms-its:c:/Program Files/SoftwareName/Generic.chm::/Generic/Introduction.htm)

This is not working, i.e. I get a script error when compiling one of my Products CHMs telling me a ')' is missing...
Also, can't I use a relative path as all my CHMs are in the same folder, instead of using an absolute path, as above?
Can someone help?

Thanks in advance for your input.
A JS newbie,
Marie-Claire
Flare 2019 r2 - Windows 10 Pro - HTML5 help / "clean" XHTML output
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: JS window.open to open a different Help File in same window

Post by NorthEast »

Try this:

window.open("mk:@MSITStore:c:/Program Files/SoftwareName/Generic.chm::/Generic/Introduction.htm", "_self");

The "_self" part opens the link in the help viewer instead of opening the topic in a browser window.

AFAIK, I think you can only use absolute and not relative paths.
(I think you can do without a path altogether if the help file name and path are added to the windows registry with the windows help files, but it's not something I've ever done.)
MC Hammer
Sr. Propeller Head
Posts: 225
Joined: Wed Aug 08, 2007 3:04 am
Location: In a galaxy far, far away

Re: JS window.open to open a different Help File in same window

Post by MC Hammer »

Hi Dave
Thanks for your valuable reply, your script seems to work. I am going to give it a good testing to make sure it is fine when going from one Help File to the other and vice-versa.
I had read somewhere that using the ms-its command was an issue with XP and service pack 2 for security reasons...

Thank you again.
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: JS window.open to open a different Help File in same window

Post by NorthEast »

I must admit I know very little about ms-its and mk:@MSITStore, and I don't know if there are any potential problems with them.

One thought though, if you want the generic topics to be available from your main product help systems, you could just merge the projects - i.e. add the generic project to the TOC of each of the main projects.

This would include a copy of all the generic topics to each help system. It'll make the files a bit bigger, but at least you won't have any problems with the link to the CHM not working (e.g. if it was installed to a different folder).
Pete Lees
Sr. Propeller Head
Posts: 150
Joined: Thu Feb 09, 2006 12:33 pm
Location: Bracknell, Berkshire, UK

Re: JS window.open to open a different Help File in same window

Post by Pete Lees »

Hi, Marie-Claire,

Do you need to use JavaScript at all for this? In most circumstances, a standard hyperlink is all that is needed to link between topics in two different .chm files. For example, this should work:

Code: Select all

<a href="ms-its:Generic.chm::/Generic/Introduction.htm"><img src="button.gif" /></a>
Provided the two .chm files are in the same folder, or the target .chm file is in the help search path, there should be no need to specify the absolute path. (A file is in the search path if it's in the current folder, or the Windows or Windows\System32 folder, or registered under the key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\HTML Help in the registry.)
using the ms-its command was an issue with XP and service pack 2 for security reasons
I don't recall ever seeing any reports of this, and haven't encountered any problems when using the ms-its protocol on XP SP2 machines. It's perhaps worth noting that most Microsoft help files use this protocol — for example, view the HTML source of any topic in the Internet Explorer help file — so it's not functionality that Microsoft would rush to disable.

All that said, you can usually dispense with the ms-its protocol prefix altogether, as every version of HTML Help in the last five years or so has not required it. So, this link should work equally well:

Code: Select all

<a href="Generic.chm::/Generic/Introduction.htm"><img src="button.gif" /></a>
Pete
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: JS window.open to open a different Help File in same window

Post by NorthEast »

Pete Lees wrote:Do you need to use JavaScript at all for this?
It's for a WebHelp toolbar button, i.e. a javascript onClick action.
Pete Lees
Sr. Propeller Head
Posts: 150
Joined: Thu Feb 09, 2006 12:33 pm
Location: Bracknell, Berkshire, UK

Re: JS window.open to open a different Help File in same window

Post by Pete Lees »

Dave Lee wrote:
Pete Lees wrote:Do you need to use JavaScript at all for this?
It's for a WebHelp toolbar button, i.e. a javascript onClick action.
So something like this ought to work?

Code: Select all

onClick="location.replace('Generic.chm::/Generic/Introduction.htm')"
Pete
MC Hammer
Sr. Propeller Head
Posts: 225
Joined: Wed Aug 08, 2007 3:04 am
Location: In a galaxy far, far away

Re: JS window.open to open a different Help File in same window

Post by MC Hammer »

Hi Pete
Thanks for your input. I tried both your solutions and none of them worked for me. As I have not got much time to play with this (deadline looming), I will go with Dave's suggestion for now.
Thanks for your help and your time.
Marie-Claire
Flare 2019 r2 - Windows 10 Pro - HTML5 help / "clean" XHTML output
Post Reply