Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
February 09, 2012, 09:07:55 PM

Pages: [1]   Go Down
  Print  
Author Topic: how do you feel about tooltips and are there any good ones  (Read 252 times)
durangod
Galactic Royalty
*****
Offline Offline

Posts: 203


« on: March 13, 2010, 07:40:47 PM »

hi i was doing some research on tooltips i would like to use them on my menus but not sure what you all thought about using them and just trying to stay out of trouble if i can.  Is there a good one you can recommend?
by good i mean easy to implement and safe to use.

it will be used on menu links for the most part so just an href  no img src
« Last Edit: March 13, 2010, 07:54:16 PM by durangod » Logged
MrPhil
Berserker Poster
*****
Offline Offline

Posts: 5083



« Reply #1 on: March 14, 2010, 07:44:41 AM »

What do you mean, "is there a good one you can recommend"? A tool tip is the little popup text box you see when you hover over something on the page. It is produced by a title="text to show" attribute on any HTML tag. You decide the text to use, if anything. As a rule of thumb, a tool tip should be an explanation or elaboration of what the image or button is about, e.g., "Click here to get help" or "Click to enlarge". It should not be a description of an image for screen readers (use alt for that).

Be aware that Internet Explorer, at least up through IE6, is brain dead and does something bad with tool tips. For images it uses the alt="descriptive text" attribute as the tool tip, if you have not also defined a title= attribute. So, for images, if you define an alt= attribute (and all non-trivial images should have one, to describe the image for the benefit of visually impaired users) always define a title= attribute, even if it's empty (title="").
Logged

durangod
Galactic Royalty
*****
Offline Offline

Posts: 203


« Reply #2 on: March 14, 2010, 09:19:34 AM »

quite understood phil, its one of the first things i learned after i started getting my sites w3c compliant, allways use a title tag and alt tag even if they are blank. 

but i think i may have lost you on my purpose for this.  i want to use a premade tooltip to tell my visitors what is in side a submenu when they run their mouse over the link, very similar to the look of the lunarpages drop down menu on their site but without all the extra coding.

the one i found is quite simple, you load some css in your css file, then you post a function on your page, then you wrap your link tag (im going to use link only, no images) and you can put in as much text as you want, i plan to use it so that when a visitor runs their mouse over it, it will tell them what is in that submenu of that link.

here is one i found, i ask about it because as simple as it seems there are some ie6 and other obj statements that i dont really understand and i want to make sure its updated is all.  i would hate to load this and then find out its outdated coding..

it comes from here but ill post t here
http://www.dynamicdrive.com/dynamicindex5/dhtmltooltip.htm



this goes in your css file or head section
Code:
<style type="text/css">

#dhtmltooltip{
position: absolute;
width: 150px;
border: 2px solid black;
padding: 2px;
background-color: lightyellow;
visibility: hidden;
z-index: 100;
/*Remove below line to remove shadow. Below line should always appear last within this CSS*/
filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135);
}

</style>


this goes in your body

Code:
<div id="dhtmltooltip"></div>

<script type="text/javascript">

/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

</script>




then you wrap your link in this

Code:
onMouseover="ddrivetip('JavaScriptKit.com JavaScript tutorials','yellow', 300)";
onMouseout="hideddrivetip()"


Logged
MrPhil
Berserker Poster
*****
Offline Offline

Posts: 5083



« Reply #3 on: March 14, 2010, 11:29:26 AM »

Yeah, you can do it that way. That's using CSS and Javascript to create a temporary pop-up with your content upon mouseover, rather than using title=. The advantage is that you get to customize the look and feel of the "tool tip" to what you want, rather than what the browser gives you. The downside is that it's extra code, may not render consistently across all browsers, and won't work if Javascript is turned off. Take your pick.
Logged

Pages: [1]   Go Up
  Print  
 
Jump to: