IT Community - Software Programming, Web Development and Technical Support

Using javascript how to show tooltip while mouse over ?

This is a discussion on Using javascript how to show tooltip while mouse over ? within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; I like to show some explanation pop up under cursor. any body tel me how can i do using javascript? ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 11-16-2007, 04:21 AM
sathian sathian is offline
D-Web Analyst
 
Join Date: Aug 2007
Posts: 252
sathian is on a distinguished road
Default Using javascript how to show tooltip while mouse over ?

I like to show some explanation pop up under cursor. any body tel me how can i do using javascript?


Thanks
Sathain
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-16-2007, 04:31 AM
KiruthikaSambandam KiruthikaSambandam is offline
D-Web Analyst
 
Join Date: Aug 2007
Posts: 332
KiruthikaSambandam is on a distinguished road
Default Re: Using javascript how to show tooltip while mouse over ?

Hi ,

Use following Code , This wil help you to show tooltip under curser.

<html>
<head>
<style type="text/css">
<!--
#tooltip {
padding: 3px;
background: #f9f9f9;
border: 1px solid #eee;
text-align: center;
font-size: smaller;
}

span.tip {
border-bottom: 1px solid #eee;
}
-->
</style>


<script>
// position of the tooltip relative to the mouse in pixel //
var offsetx = 12;
var offsety = 8;

function newelement(newid)
{
if(document.createElement)
{
var el = document.createElement('div');
el.id = newid;
with(el.style)
{
display = 'none';
position = 'absolute';
}
el.innerHTML = '&nbsp;';
document.body.appendChild(el);
}
}
var ie5 = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);
var ua = navigator.userAgent.toLowerCase();
var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
function getmouseposition(e)
{
if(document.getElementById)
{
var iebody=(document.compatMode &&
document.compatMode != 'BackCompat') ?
document.documentElement : document.body;
pagex = (isapple == 1 ? 0ie5)?iebody.scrollLeft:window.pageXOffset);
pagey = (isapple == 1 ? 0ie5)?iebody.scrollTop:window.pageYOffset);
mousex = (ie5)?event.xns6)?clientX = e.clientX:false;
mousey = (ie5)?event.yns6)?clientY = e.clientY:false;

var lixlpixel_tooltip = document.getElementById('tooltip');
lixlpixel_tooltip.style.left = (mousex+pagex+offsetx) + 'px';
lixlpixel_tooltip.style.top = (mousey+pagey+offsety) + 'px';
}
}
function tooltip(tip)
{
if(!document.getElementById('tooltip')) newelement('tooltip');
var lixlpixel_tooltip = document.getElementById('tooltip');
lixlpixel_tooltip.innerHTML = tip;
lixlpixel_tooltip.style.display = 'block';
document.onmousemove = getmouseposition;
}
function exit()
{
document.getElementById('tooltip').style.display = 'none';
}
</script>
</head>
<body>
Show <span class="tip" style="border-bottom: 1px solid #eee;"
onmouseover="tooltip('here comes the explanation');"
onmouseout="exit();"><b>tooltip</b></span> Under cursor
</body>
</html>

thanx
KiruthikaSambandam
Attached Files
File Type: txt tooltip.txt (2.2 KB, 2 views)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouse Events Pvinothkumar HTML, CSS and Javascript Coding Techniques 10 10-18-2007 12:41 AM
Windows Forms Mouse Handling Sundaram C# Programming 3 09-25-2007 08:51 AM
Mouse event varghese HTML, CSS and Javascript Coding Techniques 1 09-18-2007 08:31 AM
How can I detect mouse events with Ctrl, Alt, and Shift keys? kingmaker HTML, CSS and Javascript Coding Techniques 1 08-10-2007 03:33 AM
Any idea about Background Slide show using javascript? itbarota HTML, CSS and Javascript Coding Techniques 1 07-26-2007 12:08 AM


All times are GMT -7. The time now is 12:42 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0