Skip To Main Content | Home | Sitemap | Contact

How can you have mouse over tool tip definitions in a styled division?

Mark the definition terms in the test with the <dfn>...</dfn> tags. Add an inline onmouseover event to the opening <dfn> tag which sends the term and the event to our show definition function. Create a styled division at the bottom of the page to hold the definition words. Get the mouse position of the mouseover event, put the correct definition words in the division and set it's top and left position to the mouse position.
Charles Ponzi (March 3, 1882 – January 18, 1949) was one of the greatest swindlers in American history. His aliases include Charles Ponei, Charles P. Bianchi, Carl and Carlo. The term "Ponzi scheme" is a widely known description of any scam that pays early investors returns from the investments of later investors. He promised clients a 50% profit within 45 days, or 100% profit within 90 days, by buying discounted postal reply coupons in other countries and redeeming them at face value in the United States as a form of arbitrage. Ponzi was probably inspired by the scheme of William F. Miller, a Brooklyn bookkeeper who in 1899 used the same scheme to take in $1 million. HTML stands for hypertext markup language.


<!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>Mouse Over Tooltip Definitions</title>
<script type="text/javascript">
function showDef(pTerm,e) {
    // to hold the mouse position
    var tempX;
    var tempY;

    // get the mouse position (add a little to Y to be below the term
    if (window.event) {
        tempX = event.clientX + document.body.scrollLeft + 10;
        tempY = event.clientY + document.body.scrollTop;
    } else {
        tempX = e.pageX;
        tempY = e.pageY + 10;
    }

    // based on the term, put the correct definition in the division
    switch (pTerm) {
      case'arbitrage':
          document.getElementById('innerDiv').innerHTML = '<emphasize>arbitrage</emphasize>: The practice of taking advantage of a price differential between two or more markets: striking a combination of matching deals that capitalize upon the imbalance, the profit being the difference between the market prices.'; 
          break;
      case'Brooklyn':
          document.getElementById('innerDiv').innerHTML = '<emphasize>Brooklyn</emphasize>: New York City\'s most populous borough, with 2.5 million residents, and second largest in area.';
          break;
      case'investments':
          document.getElementById('innerDiv').innerHTML = '<emphasize>investments</emphasize>: The active redirection of resources/assets to creating benefits in the future; the use of resources/assets to earn income or profit in the future.';
          break;
      case'Ponzi scheme':
          document.getElementById('innerDiv').innerHTML = '<emphasize>Ponzi scheme</emphasize>: A fraudulent investment operation that pays returns to separate investors from their own money or money paid by subsequent investors, rather than from any actual profit earned.';
          break;
      case'profit':
          document.getElementById('innerDiv').innerHTML = '<emphasize>profit</emphasize>: The making of gain in business activity for the benefit of the owners of the business.';
          break;
      case'redeeming':
          document.getElementById('innerDiv').innerHTML = '<emphasize>redeeming</emphasize>: To recover ownership of by paying a specified sum; for example: to pay off a promissory note.';
          break;
      case'swindlers':
          document.getElementById('innerDiv').innerHTML = '<emphasize>swindlers</emphasize>: Persons practicing quackery or some similar confidence trick in order to obtain money, fame or other advantages via some form of pretence or deception.';
          break;
    }
    // show the division at the mouse position
    document.getElementById('defDiv').style.display='block';
    document.getElementById('defDiv').style.top=tempY+'px';
    document.getElementById('defDiv').style.left=tempX+'px';
}

function closeDef() {
    // if the division is clicked, hide it.
    document.getElementById('defDiv').style.display='none';
}
</script>
<style type="text/css"> 
.definition {
    border-bottom: 3px double #0000FF;
}

#defDiv {
    background-image: url('images/defdivbg.gif');
    background-repeat: no-repeat;
    background-position: left top;
    position:absolute;
    width:257px;
    height:156px;
    display:none;
    padding-top:35px;
    padding-right:45px;
    padding-bottom:10px;
    padding-left:5px;
    font-size:9pt; 
}

#innerDiv {
	margin:0px 20px 10px 10px;
}
</style>
</head>

<body>
<div id="theExample">
Charles Ponzi (March 3, 1882 – January 18, 1949) was one of the greatest <dfn class="definition" onmouseover="showDef(this.innerHTML,event)">swindlers</dfn> in American history. His aliases include Charles Ponei, Charles P. Bianchi, Carl and Carlo. The term &quot;<dfn class="definition" onmouseover="showDef(this.innerHTML,event)">Ponzi scheme</dfn>&quot; is a widely known description of any scam that pays early investors returns from the <dfn class="definition" onmouseover="showDef(this.innerHTML,event)">investments</dfn> of later investors. He promised clients a 50% <dfn class="definition" onmouseover="showDef(this.innerHTML,event)">profit</dfn> within 45 days, or 100% profit within 90 days, by buying discounted postal reply coupons in other countries and <dfn class="definition" onmouseover="showDef(this.innerHTML,event)">redeeming</dfn> them at face value in the United States as a form of <dfn class="definition" onmouseover="showDef(this.innerHTML,event)">arbitrage</dfn>. Ponzi was probably inspired by the scheme of William F. Miller, a <dfn class="definition" onmouseover="showDef(this.innerHTML,event)">Brooklyn</dfn> bookkeeper who in 1899 used the same scheme to take in $1 million.
</div>
<div id="defDiv" onclick="closeDef();"><div id="innerDiv">&nbsp;</div></div>
</body>

</html>
  


This Weeks Most Popular Pages Newest Pages