Highlighting Search Results

What's covered?

This topic describes Calvin Ly's method of highlighting search results in webhelp.

You can read about the method on Calvin's site where there is a demo together with a downloadable javascript file.

All I have done here is describe the method in a little more detail for the benefit of authors who are less familiar with using javascript. I have also created a RH project that you can download to see the source files.

RoboHelp X5 and RoboHelp 6

Two ways of implementing Calvin's script are described. They will work in webhelp generated from RoboHelp HTML X5 and RoboHelp 6. They may appear to work if you try them in earlier versions but there will probably be clashes with other functionality. If your topic has any RoboHelp dropdowns in it, you must use Method One.

If your topics were created by importing from Word or Framemaker, you may find that dropdowns in those topics no longer work after searching. Don't ask why but if you remove these two metatags, the problem will be fixed.

<meta name=Originator content=etc>
<meta name=OriginalFile content=etc>

The functionality can only be demonstrated in a RoboHelp project.

Click here to open a demonstration.

Click here to download the RoboHelp project so that you can see exactly how it is set up.

RoboHelp 7

If you have RoboHelp 7, then Search Highlighting is now part of the standard functionality. If you have implemented Calvin Ly's method in a project that you are now upgrading, here is my response to an enquiry I had about whether to leave it in and whether any issues would arise.

"I haven't tested what you ask but I don't think continuing to use that method would do any harm. That said, you need to remember to add the necessary javascript to each topic and if you move on, will your successor know about it?

Personally I think I would remove it and that should be straightforward. The advantage of doing it the RoboHelp 7way is you have control over the highlight colour and no future worries about including the script.

There will be two search and replace operations.

Find and Replace 1

Search for

<body onLoad="beginSearch ()">

and replace it with

<body>

The only thing to watch for there is that you don't have any other references in the body tag.

Find and Replace 2

The next one is a bit more difficult. You need to search for the following and remove it.

<script language=JavaScript src="highlight.js"></script>

Why is that difficult? Because in most cases that line will in fact be written on two lines in your html and that means the RoboHelp's MultiFile find and replace won't find it. The most reliable tool would be FAR from www.helpware.net. Be careful even then that it does not find the start of one script and delete everything between that and the end of this one. It should be possible to ensure that but backup first and go carefully at first.

Also remember that you may have references to

<script language=JavaScript src="highlight.js"></script>

<script language=JavaScript src="../highlight.js"></script>

<script language=JavaScript src="../../highlight.js"></script>

and so on so there will be several passes of the find and replace."

Date

Changes to this page

30 Oct 2007 How to remove the method added for RoboHelp 7 users.
17 Jul 2007 Updated to specify the method works in RoboHelp 6. Also that topics created by importing from Word or Framemaker may need a code edit.

24 Jan 2006

This page created as part of the new site. Launches a demo RoboHelp project.