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. 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. See AutoExpand for information on the versions of RoboHelp that this method works with. |
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:
- Create the function in a javascript file.
- Create a reference to that file in the target topic,
- Load the function whenever the topic is opened.
- 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 |
|
|
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
- Add the text or graphic that will point to the target topic.
- Highlight the text or graphic and click the Insert Hyperlink icon.
- Point to the target file so that its name appears in the Link To field.
- 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.

Donations
If you find the information and tutorials on my site save you time figuring it out for yourself and help improve what you produce, please consider making a small donation.
Topic Revisions
![]()
Date |
Changes to this page |
| 18 Jun 2009 | Information re compatibility removed. Link added to AutoExpand topic instead. |
| 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. |
