Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tool tip definition populated from glossary file

Status
Not open for further replies.

BFP

Technical User
May 18, 2000
52
0
0
US
Hi all.

Total hack here creating a HTML-based help system for an HTML-based tool that has hundreds of screens with similar fields (e.g. "Company Name").

Since there are so many fields that are repeated throughout the tool, I wanted to create a single glossary file with a name anchor for each entry.

I thought it would be great if I could show a tool tip that is the short glossary entry when the user hovers the mouse over the link. So to keep it simple, I thought if I could populate the title of the link automatically with the glossary entry, it would save the user from having to ever view this massive glossary.

For example, if my target file contained
Code:
<a href="glossary.html#CompanyName">Company Name</a>
And glossary.html contained
Code:
<p><a name="CompanyName" id="CompanyName"></a>The name of the company. </p>
Then the tool tip would automatically be populated with
[tab][tt]The name of the company[/tt]
when the mouse hovers over the link.

Is this possible?

Thanks in advanced.

BFP
 
Yes.

Use this to get an array of all anchors on the page:

Code:
var anchors = document.getElementsByTagName('a');

Then loop through the array checking the "href" attribute. Do a simple string test to see if there's a bookmark ("indexOf('#')"), and strip off everything after it.

If it matches one of your glossary items, them add a title field.

You might need to do an AJAX call to check each item against a glossary, or you might deliver the whole glossary to the page in an array, etc.

Personally, I think you are MUCH better off doing this server-side before the page is delivered for two reasons:

1) It will work even if the user has JS disabled, and
2) It will be instant, so no delay for accessing the glossary.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks Dan

Don't know the first thing about AJAX, or how to "do this server-side before the page is delivered" but I'll give it a shot.

Has anyone ever done a study to find out how many people turn off JavaScript (especially IT departments for large corporations)?

Thanks,

BFP

 
BFP said:
Has anyone ever done a study to find out how many people turn off JavaScript

Indeed they have, it's a small percentage, but not small enough to be dismissed outright IMHO.


[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Webflo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top