Auto Expand - Method 1

What's covered?

This topic describes the original method devised by Rick Stone to whom credit goes for amending a script from Tommy Simmons.

What I have done is demonstrate it and explain how to tweak it when there is more than one target in a particular topic. I have also amended the method so that it can be used with expanding text.

The Demo

Click this link to see the demo.

The Method

In the target file you need a javascript function for each target dropdown or expanding hotspot. For good order I have called them showEmMark1(), showEmMark2() etc.

The script from the target file for the links above is as below.

<script type="text/javascript"

language=JavaScript1.2>

var arrayofDivs = document.all.tags("DIV");

var arrayofSpans = document.all.tags("SPAN");

// FIRST FUNCTION

function showEmMark1()

{ arrayofDivs[0].style.display = "block";

}

if (window.location.hash.substring(1)=="First"){

setTimeout('showEmMark1()',500);}

// SECOND FUNCTION

function showEmMark2()

{ arrayofDivs[1].style.display = "block";

}

if (window.location.hash.substring(1)=="Second"){

setTimeout('showEmMark2()',500);}

// THIRD FUNCTION

function showEmMark3()

{ arrayofSpans[0].style.display = "inline";

}

if (window.location.hash.substring(1)=="Third"){

setTimeout('showEmMark3()',500);}

</script>

 

The points to note are:

  1. The function name on the first line must match the name in the last line of that function.
  2. Functions for dropdown hotspots will show a variable "arrayofDivs". This will be followed by a number which is the sequence number of the dropdown spot in the topic starting with the number 0.
    If the topic has ten dropdown spots and your targets are the first and last dropdown spot, then the numbers in the two functions covering dropdown text will be 0 and 9. Do not count any expanding hot spots in the sequence.
  3. Functions for expanding hotspots will show a variable "arrayofSpans". This will be followed by a number which is the sequence number of the expanding spot in the topic starting with the number 0.
    If the topic has ten expanding spots and your targets are the first and last expanding spot, then the numbers in the two functions covering expanding text will be 0 and 9. Do not count any dropdown hot spots in the sequence.
  4. The value in the line
    if (window.location.hash.substring(1)=="First"){
    will be the name of the bookmark in the target topic, in this example it is "First" etc.
  5. Go to each hotspot that you want to be called by a hyperlink from another topic and apply a bookmark.
  6. Create the link to the target topic and bookmark in the usual way. It will look something like this
    <p><a href="target.htm#First">Link 1</a></p>