
What's covered?This topic describes a method of creating links in your source files that will not be seen by users of the default help but will be seen if a javascript file in the output is edited. This enables customers to "create" links where required for their users. Typically these will be links to internal documentation or an intranet describing company specific procedures. The method is available for both webhelp and compiled chm help, albeit using different scripts and procedures. |
The costs associated with customising help topics explained in Customising Help will deter many customers and they will then seek an alternative. Often the request is along the lines of requesting some links to their own Word documents, PDF files, an intranet and so on.
Previously this has required some fairly clunky solutions but with the aid of some javascript, a rather more elegant solution is now available. Many thanks to my colleague Tony Harris for his work in producing this script which has some very neat options and to Pete Lees for making it work with compiled .chm help.
In the creation of every topic in the standard help, a piece of javascript is inserted (there are ways of adding it retrospectively to existing help topics). What this does each time a topic is opened is:
Click these links or those in the Table of Contents to see it work.
Demo Topic 1 - Shows a topic where nothing has been defined in the javascript file.
Demo Topic 2 - Shows a link with the default text.
Demo Topic 3 - Shows a link with alternative text.
Demo Topic 4 - Shows an image that links to a website in a new window.
These two illustrations show the same topic, firstly as it was supplied to the customer and then after they had amended the script as described in the next section. Exactly what you want, the link is displayed only in topics where it is required. It can point to additional or alternative procedures.


The beauty of this method is that the script is installed once in the source files and the work is then done by the customer who has control over the cost.
This section describes the set up for the technical author. What the customer has to do with the installed help files is covered in the next section. Whilst these instructions were written for RoboHelp users, they can be used with any HTML editor.
You need to decide upon a standard place to insert the script. My suggestion is that it goes immediately below the heading for the topic. Customers using the idea can then train their staff that they click this link instead of the help or as well as, it depends on whether they are providing alternative help or supplementary help.
Please note that the scripts and procedures for webhelp and compiled chm help are different.
If you are producing webhelp:
In the RoboHelp WYSIWYG editor you will see a red square where the script has been inserted. If you click on Preview, you will get an error message which can be ignored and you will then see the topic. The red square will not be displayed but the link can only be seen at the output stage.
If you are producing compiled chm help:
In the RoboHelp WYSIWYG editor you will see a red square where the script has been inserted. If you click on Preview, you will get an error message which can be ignored and you will then see the topic. The red square will not be displayed but the link can only be seen at the output stage.
The logic behind the script is that if nothing is done with the custom_linklist.js or the custom_linklist_chm.js files in the output, then no links will be displayed.
If however, the required lines are added to the custom_linklist.js or the custom_linklist_chm.js files in the output, then the link will be displayed in accordance with the settings. This is described in more detail in What the Customer Does.
If your help has not yet been written, You could add the lines to a template so that it automatically gets added to every topic.
If the help has been written, consider using a multi file find and replace tool to paste the script into the same location in every source file.
If your topics were based on a template, you could add the script to the header or footer and then choose to apply it to all topics based on that template. You would need to consider whether that would impact on any other header and footer information in a topic based on that template.
However you do it, bear in mind that for webhelp you need to amend the relative paths if you have topics at different folders levels (the relative path to the javascript files will vary for each level).
Just generate your help in the normal way. No links will be seen in the initial output and nothing will appear in any printed documentation you create from the source files. As the links are customer specific, this is the desired result anyway.
If you have to produce both webhelp and compiled chm help, you will need to follow both procedures above and use conditional text.
Using a text editor, the customer opens the custom_linklist.js or custom_linklist_chm.js file as appropriate in the output. The custom_link.js and custom_link_chm.js files require no editing.
The act of generating webhelp will place a blank custom_linklist.js file in the output. If you are generating compiled chm help then you will need to manually add a blank custom_linklist_chm.js file to the same location as the chm file.
The instructions have been written into the custom_linklist.js and custom_linklist_chm.js files. The screenshot below shows the custom_linklist.js file as it is supplied in the webhelp output. Note the empty lines above the comments. The detail of the instructions in the custom_linklist_chm.js file is different to the webhelp version shown below.

The procedures in rest of this topic relate are written specifically for webhelp. You will need to slightly modify them for compiled chm help.
First let's look at adding a single link in one file. The customer simply creates a new line above the comments using either of the options:
To start with the links will look like this
addLink("","",null,null);
OR
addLinkExternal("","",null,null);
Both types of link are completed in the same way.
An example line might be
addLink("demo.htm","procedure.pdf",null,null);
OR
addLinkExternal("demo.htm","http://www.website.xxx",null,null);
Click here for more more examples.
Although the script <script language=JavaScript src="custom_linklist.js"></script> can only be inserted once in any topic, it can display more than one link at that location.
So if the customer want two procedures shown, say one for North Region and one for South Region, two lines would be created something like this:
addLink("demo.htm","north.pdf",null,"<p class=Custom>Click here for North Region instructions.</p>");
addLink("demo.htm","south.pdf",null,"<p class=Custom>Click here for South Region instructions.</p>");
In the output, it would look something like this.

If you particularly need links in more than one location in the file there are two options:
It is vital the customer is aware that they must keep a copy of the custom_linklist.js or custom_linklist_chm.js file with all their addLink rows so that it can be restored if the help is overwritten at any time, for example when the software is upgraded.
If the customers place any target files within the help structure, they must ensure that they are also backed up.
Click here to download a mini project demonstrating how things are set up and showing the links as the customer will see them, or not!
To run the demo, extract the files using WinZip's extract function to preserve the structure. Then go to \!SSL!\WebHelp and run the index.htm file.
To alter what is displayed, you need only edit the custom_linklist.js file in the output. If you want to generate your own output, I suggest you create it in a new folder so as to retain the supplied output.
For the javascript files that you will require in your project, use the custom_link.js and custom_linklist.js files that are in the root of the demo project, not those in the demo output.
Click here to download a mini project demonstrating how things are set up and showing the links as the customer will see them, or not!
To run the demo, extract the files using WinZip's extract function to preserve the structure. Then go to \!SSL!\Microsoft_HTML_Helpand run the helpfile.
To alter what is displayed, you need only edit the custom_linklist_chm.js file. If you want to generate your own output, I suggest you create it in a new folder so as to retain the supplied output.
For the javascript files that you will require in your project, use the custom_link_chm.js and custom_linklist_chm.js files that are in the root of the demo project, do not use the custom_lnklist_chm.js file in the demo output.
![]()
Date |
Changes to this page |
| 21 Apr 2007 | Link added to more examples. |
| 25 Feb 2005 | Clarified that method is not RoboHelp specific. Can be used with any editor. |
| 26 Aug 2005 | Text for first parameter in custom_linklist.js revised. Screenshot updated and downloads amended. |
| 28 May 2005 | Instructions revised to cover set up with a compiled chm file. |
| 08 May 2005 | "What's covered?" amended to make it clearer and to note the method can now be used with compiled chm help. |
| 05 Mar 2005 | Order of demos changed to make it more progressive. |
| 20 Jan 2005 | Instructions re amending relative path revised to recommend using a forward slash. |
| 18 Jan 2005 | Demo incorporated within site so that it is no longer necessary to download it to see it working. The download is still available. Additional download with just the javascript files available. |
| 17 Jan 2005 | Revised custom_link.js file made available allowing duplicate file names to be included in the custom_linklist.js file. Instructions and demo download amended accordingly. |
| 16 Jan 2005 | Note added advising that the method has been tested with CHM output and is not compatible. |
| 14 Jan 2005 | The sentence "Unless the file is in the same folder as the javascript, the relative path will be required using forward slashes." has been removed from Step 1 of the customer actions. See Step 1 for reason. |
| 10 Jan 2005 | Completely revised with a different script that saves the customer having to rewrite all the links in the event of the help being upgraded. The new script also permits images to be used instead of a text link and for a file to have multiple link. |
| 09 Jan 2005 | New topic. |