Skip To Main Content | Home | Sitemap | Contact
Latest Visitors: United States's flagUnited States's flagUnited States's flagUnited States's flagUnited States's flagItaly's flagIndia's flagIndia's flagUnited States's flagFrance's flagRussian Federation's flagGermany's flagIsrael's flagItaly's flagUnited States's flagChina's flagChina's flagUnited States's flagIndia's flagUnited States's flagUnited States's flagChina's flagUnited States's flagRussian Federation's flagChina's flag
 

How can you highlight glossary terms on a page (and skip hyperlinks)?

This example was written in response to a question Q_21517532 posted on Expert's Exchange.  The original question was how to highlight glossary terms, add a tooltip with a description related to the term and offer a link to the term's definition in another page.
Example: The FBI's (FBI) Internet Fraud Complaint Center (IFCC) reports a steady increase in complaints involving unsolicited e-mails directing consumers to a phony "customer service" Web site or directly asking for customer information. These scams are contributing to a rise in identity theft, credit card fraud, and other Internet-based frauds. E-commerce customers, including bank customers, have fallen victim to these scams.

Phishing involves sending customers a seemingly legitimate e-mail request for account information, often under the guise of asking the customer to verify or reconfirm confidential personal information such as account numbers, social security numbers, passwords, and other sensitive information. In the e-mail, the perpetrator uses various means to convince customers that they are receiving a legitimate message from someone whom the customer may already be doing business with, such as a bank. Techniques such as a false “from” address or the use of seemingly legitimate bank logos, Web links, and graphics may be employed to mislead the customer. After gaining the customer’s trust, the perpetrator attempts to convince the customer to provide personal information and provides one or more methods for the customer to communicate that information back. For example, the e-mail might include a link to the perpetrator’s Web site that contains a form for entering personal information. Like the e-mail, the Web site is designed to trick the customer into believing it belongs to the bank. Alternatively, the e-mail might simply include an embedded form for the customer to complete. The ultimate goal of this fraud is to use the customer information to gain unauthorized access to a customer’s bank or financial accounts or to engage in other illegal acts.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="author" content="Roderick Divilbiss">
<meta name="copyright" content="© 2005-2010 Roderick Divilbiss">
<title>Highlight Glossary Terms</title>
<script type="text/javascript">

var terms = new Array();
terms[0] = ['FBI','Federal Bureau of Investigation','definition.asp#fbi'];
terms[1] = ['e-mail','electronic mail','definition.asp#email'];
terms[2] = ['phony','not true, fake.','definition.asp#phony'];

function highlightGlossaryTerms(){
  // AVOID <a...>..</a> tags
  var temp = document.getElementById('theExample').innerHTML;
  var tmpBody = new Array();
  // segregate the anchors
  var cnt=0;
  var inA=false;
  var lookIn='';
  var subBody;
  var tmpStr;

  while (temp.length>0) {
    if ((temp.indexOf('</A>')>-1)||(temp.indexOf('<A')>-1)) {
      if (inA) {
        tmpBody[cnt]=temp.substr(0,temp.indexOf('</A>')+5);
        temp=temp.substr(temp.indexOf('</A>')+4);
        inA=false;
        cnt+=1;
      }else{
        tmpBody[cnt]=temp.substr(0,temp.indexOf('<A')-1);
        temp=temp.substr(temp.indexOf('<A')-1);
        inA=true;
        lookIn+=''+cnt+',';
        cnt+=1;
      }
    }else{
      tmpBody[cnt]=temp;
      temp='';
      lookIn+=''+cnt+',';
    } 
  } 
  lookIn=lookIn.substr(0,lookIn.length-1);

  for (var idx=0;idx<terms.length;idx++){
    for (var hdx=0;hdx<tmpBody.length;hdx++) { 
      if (lookIn.indexOf(hdx)>-1) {
        subBody=tmpBody[hdx].split(terms[idx][0])
        tmpStr=subBody[0];
        for (var jdx=1;jdx<subBody.length;jdx++) {
          tmpStr+='<a href="'+terms[idx][2]+'" class="terms" title="'+terms[idx][1]+'">'+terms[idx][0]+'<\/a>'+subBody[jdx];
        }
        tmpBody[hdx]=tmpStr;
      }
    }
  }
  tmpStr='';
  for (var idx=0;idx<tmpBody.length;idx++)
    tmpStr+=tmpBody[idx];
  document.getElementById('theExample').innerHTML=tmpStr;
}
</script>
<style type="text/css">
.terms { 
    font-weight: bold;
    background-color: #FFFF66;
    text-decoration:underline;
    color:#800000;
}
</style>

</head>

<body>
<div id="theExample">
<strong>Example:</strong>

The FBI's Internet Fraud Complaint Center (IFCC) reports a steady increase in complaints involving unsolicited e-mails directing consumers to a phony &quot;customer service&quot; Web site or directly asking for customer information. These scams are contributing to a rise in identity theft, credit card fraud, and other Internet-based frauds. E-commerce customers, including bank customers, have fallen victim to these scams.<br>
<br>
Phishing involves sending customers a seemingly legitimate e-mail request for account information, often under the guise of asking the customer to verify or reconfirm confidential personal information such as account numbers, social security numbers, passwords, and other sensitive information. In the e-mail, the perpetrator uses various means to convince customers that they are receiving a legitimate message from someone whom the customer may already be doing business with, such as a bank. Techniques such as a false &#8220;from&#8221; address or the use of seemingly legitimate bank logos, Web links, and graphics may be employed to mislead the customer. After gaining the customer&#8217;s trust, the perpetrator attempts to convince the customer to provide personal information and provides one or more 
methods for the customer to communicate that information back. For example, the e-mail might include a link to the perpetrator&#8217;s Web site that contains a form for entering personal information. Like the e-mail, the Web site is designed to trick the customer into believing it belongs to the bank. Alternatively, the e-mail might simply include an embedded form for the customer to complete. The ultimate goal of this fraud is to use the customer information to gain unauthorized access to a customer&#8217;s bank or financial accounts or to engage in other illegal acts.<br>
</div>
<script type="text/javascript">highlightGlossaryTerms();</script>
</body>

</html>


This Weeks Most Popular Pages Newest Pages