Auto Expand - Method 2

What's covered?

This topic describes a method produced by Christina Maier and sent to me by Mike Kalmbach. It is very simple, don't be put off by the length of the explanation.

This method works in RH Version X3 but not X5 (I have been advised that it does work in X5.0.2 so maybe the patch fixed it). Because I no longer have access to RH X3, there is no demo. From the users point of view it works in the same way as the Method 1 Demo.

Note that every link you create will falsely report as a broken link. However, the links do work in the published webhelp or chm file and you can "mark" them using the method devised by Mike Kalmbach.

The Method

The target file needs a javascript function to be loaded when the page is opened by the call from the links shown above. This automatically causes the dropdown or expanding text to be shown when the page opens in response to clicking the link to it.

The basic steps are:

  1. Create the function in a javascript file.
  2. Create a reference to that file in the target topic,
  3. Load the function whenever the topic is opened.
  4. Create the links where required.

Create the Function

The script for the function is

function openlink(){

y=window.location.hash.substring(1);

if (!y) return;

x=document.getElementById(y);

kadovTextPopupOnLoad(x);

kadovTextPopup(x);

}

 

I suggest you put this script in a text editor and save the file as say openlink.js. Save the file in the root of your project.

You can however add the function to the ehlpdhtm.js file if you prefer.

For

Against

  • You can skip the next step.
  • If the ehlpdhtm.js is overwritten because of a RoboHelp upgrade, the function will be lost.
  • It is a bit less obvious to anyone who follows you.
  • Don't expect Macromedia to support an amended ehlpdhtm.js file.

 

Reference the Javascript File

If you save the function to openlink.js, then in the target file you need to add a reference to that file by adding the lines below to the <head> section of the target page. If the target file is not in the root of your project, you need to amend the last line to provide a relative path. Thus if the target is one level down from the root, you need to amend it to src="..\openlink.js"></script>

<script type="text/javascript"

language=JavaScript1.2

x-save-method=compute-relative

src="openlink.js"></script>

 

Load the Script

Amend the <body> tag of the page to

<body onLoad="openlink()">

This runs the function whenever the topic is called and works with the link to open the required dropdown or expanding text.

Create the Links

Locate the Target ID

In the target file, highlight the dropdown hotspot and click the True Code tab. The highlighted html will look something like the example below. Note down the ID which I have highlighted in blue. The html for expanding will be a little different but it still has an ID.

<p><a class=dropspot

x-use-popup=#POPUP234380326

x-popup-type=pulldown

href="javascript:kadovTextPopup(this)"

id=a2>First dropdown</a><!--begin!kadov{{--><script type="text/javascript"

language=JavaScript1.2><!--

kadovTextPopupInit('a2');

//--></script><!--}}end!kadov--></p>

 

Create the Link

  1. Add the text or graphic that will point to the target topic.
  2. Highlight the text or graphic and click the Insert Hyperlink icon.
  3. Point to the target file so that its name appears in the Link To field.
  4. Add a hash after the file name (no spaces) and then the ID (again no spaces). It should look something like targetfile.htm#a1

Compile

That's it. Just create your webhelp or chm file and test the links.

False Broken Links

As indicated at the beginning, all the links you create this way will report as broken. You cannot avoid that but you can "mark" the links that you create using this method.

In the example above, the ID of the target link is a2. You can change that to whatever you like as long as you use the changed ID when you create the link. One option, as suggested by Mike Kalmbach who sent me this method, is to prefix it DDH_ (DDH for Drop Down Hotspot). The broken links will then appear as below. You need to check before you generate or compile the help that the broken links all have this prefix. Any that do not are, on the face of it, true broken links.

Date

Changes to this page

02 Dec 2007 Note added that report received indicating Method 2 does work in X5.0.2.
20 Dec 2004 Topic updated to reflect that this method does not work with RH X5 output.
22 May 2004 Method of highlighting the false broken links added.