To insert the JavaScript code

Microsoft HTML Help

To insert the JavaScript code

Insert the following JavaScript functions between the <HEAD> start and end tags of the page:

<SCRIPT LANGUAGE="JavaScript">
<!--
function function1Name(idVariable){
//display the section if it's not displayed; hide it if it is displayed
if (idVariable.style.display=="none"){idVariable.style.display=""}
else{idVariable.style.display="none"}
}
function function2Name(idVariable){
//remove the section when user clicks in the opened DIV
if (idVariable.style.display==""){idVariable.style.display="none"}
}
-->

Where function1Name and function2Name are the names of each function, and idVariable is the variable for the unique ID that is passed to the script each time a user clicks the link.

Example

The following is the actual JavaScript code used in the HTML Help documentation:

function doSection (secNum){
//display the section if it's not displayed; hide it if it is displayed
if (secNum.style.display=="none"){secNum.style.display=""}
else{secNum.style.display="none"}
}

function noSection (secNum){
//remove the section when user clicks in the opened DIV
if (secNum.style.display==""){secNum.style.display="none"}
}

Notes

  • You can use a global script file to store all of your scripts in one location. This can make it much easier to maintain scripts that are used on multiple topics in a help system.