Solved

Displaying text only when onMouseOver event occurs

Posted on 2002-07-15
7
176 Views
Last Modified: 2008-03-17
Hello,
I would like to display text in an area only when an onMouseOver event occurs.
For example.
If I have a calendar on a page I would like to have events for the dates. When a user puts their mouse over the date or event on that date then a description of that event is displayed below the calendar. When they move the mouse away then the description of that event is no longer displayed.

How may this be possible.

Thanks,
Ivan
0
Comment
Question by:icarey
7 Comments
 
LVL 30

Expert Comment

by:third
ID: 7156163
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 7156246
<html>
<head>
<title>Tooltips</title>
</head>
<body>
<a nohref onmouseover="document.all.tooltip1.style.visibility='visible'" onmouseout="document.all.tooltip1.style.visibility='hidden'">This is My Text</a>
<div id="tooltip1" style="display;block; position:absolute; visibility:hidden; top:10px; left:10px; height:10px; width:100px; font-family:verdana; font-size:9px; border:1px solid #cccccc; background-color:#eeeeee">
This is my tooltip
</div>
</body>
</html>





or





<a nohref title="Your ToolTip">Your Text Here</a>
0
 
LVL 2

Expert Comment

by:mgaurav
ID: 7156263
<form name="myForm">
<textarea name="comments" value=""></textarea>
</form>

<a href="javascript://" onmouseover="tooltip('details')" onmouseout="tooltip('')" onclick="return false;">July 16, 2002</a>


<script>
 function tooltip(tip)
 {
   document.myForm.comments.value = tip;
 }
</script>


HIH,
mGaurav
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:zeheb
ID: 7156789
<SCRIPT LANG="JavaScript">
    function ShowText()
    {
        document.all.item("DisplayText").innerText = "Some Text"
    }
   
    function HideText()
    {
        document.all.item("DisplayText").innerText = ""
    }
</SCRIPT>
</HEAD>
<BODY>
    <SPAN ID="DisplayText" OnMouseOver="JavaScript:ShowText()" OnMouseOut="JavaScript:HideText()">
    &nbsp
    </SPAN>
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 200 total points
ID: 7157053
If you want it cross-browser, it get very limited because netscrap 4.x
only supports mouse over for links images and layers

<html>
<!-- cross-browser text display dynamically from mouseoveR a link
-->
<style>
   .EVNTcls {visibility:hidden;position:absolute;top:250;left:40}
   a:hover {color:white;background-color:blue}
</style>
<script language="JavaScript">
<!--
   var ACTIVElist=false;
// browser detection using DOM detection:

if (document.getElementById)
{
   var LoLev=false;
   var HiLev=true;
   var IE5=(document.all) ? true : false;
   var NS6=(!document.all) ? true : false;
}
else
{
   var HiLev=false;
   var LoLev=true;
   var IE4=(document.all) ? true : false;
   var NS4=(document.layers) ? true : false;
}

   function ShowBlock(EL)
   {
      if (NS4)
      {
         ACTIVElist=document.layers[EL];
      }
      else
      {
         if (IE4)
         {
            ACTIVElist=document.all[EL].style;
         }
         else
         {
            if (HiLev)
            {
               ACTIVElist=document.getElementById(EL).style;
            }
         }
      }
      ACTIVElist.visibility="visible";
   }
//-->
</script>
</head>
<body>

<div id="linklst" style=position:absolute;left:40;top:100">
   <a href="blah1.htm" onMouseOver="ShowBlock('id1')"
                       onMouseOut="ACTIVElist.visibility='hidden'"> blah1
   </><br /><br />
   <a href="blah2.htm" onMouseOver="ShowBlock('id2')"
                       onMouseOut="ACTIVElist.visibility='hidden'"> blah2
   </a><br /><br />
   <a href="blah3.htm" onMouseOver="ShowBlock('id3')"
                       onMouseOut="ACTIVElist.visibility='hidden'"> blah3
   </a><br /><br />
   <a href="redirect_back.htm" onMouseOver="ShowBlock('id4')"
                       onMouseOut="ACTIVElist.visibility='hidden'"> blah4
   </a><br /><br />
</div>
<div id="id1" class="EVNTcls">
   JULY 15TH EVENTS<br />
   1st event for July 15<br />
   another event for July 15th<br />
   etc
</div>
<!-- each list is in its own layer with only one visible at a time
-->
<div id="id2" class="EVNTcls" >
   JULY 16TH EVENTS<br />
   1st event for July 16<br />
   another event for July 16th<br />
   etc
</div>
<div id="id3" class="EVNTcls">
   JULY 17TH EVENTS<br />
   1st event for July 17<br />
   another event for July 17th<br />
   etc<br />
   etc ;)<br />
   etc [:)<br />
   etc {:x)<br />
   etc :=)<br />
   etc B}<br />
</div>
<div id="id4" class="EVNTcls">
   JULY 18TH EVENTS<br />
   1st event for July 18<br />
   another event for July 18th<br />
   etc
</div>
</body>
</html>

If you do not need to support Netscrap 4.x then you can put the
mouse events on any tag.

Cd&
0
 
LVL 3

Author Comment

by:icarey
ID: 7166083
Thanks to all for your answers
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7166710
Glad we could help. Thanks for the A. :^)

Cd&
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question