PDA

View Full Version : DHTML Tooltip - Overlap with normal element



meximex
05-14-2006, 01:23 PM
hi,
i combined the "dhtml tooltip" with an image preview on mouse-over

now form elements like select-boxes overlap the preview.. this is just in IE..
the z-index of the div is at 100... the form is in no layer.

what could help?

thx so far!

jscheuer1
05-14-2006, 05:37 PM
Hide[1] the form elements or use an iframe shim[2] to cover them. Do this for IE only and only when the tool tip is visible.

Or, move the form element in your layout so that it can never conflict with a tip.

This is an IE only bug and hopefully will be fixed in IE7.

[1] Create and add code to the script that will set the style.visibility='hidden' for the form element(s) while the tool tip is displayed and return that to 'visible' when the tip disappears.

[2] Create and add code to the script that, using z-index style, places a blank iframe of the same dimensions underneath each tool tip while it is displayed and removes said iframe when the tip disappears.

AshleyQuick
05-15-2006, 02:47 PM
How would this be done? I'm having the same difficulties.

jscheuer1
05-15-2006, 03:51 PM
For the hiding method see:

http://www.dynamicdrive.com/forums/showthread.php?p=11343

particularly post#6. I'm not aware of anyone working out the details of the iframe shim method for these scripts (there are two versions of DHTML tool tip on DD here). I'll have a look into it but, no promises.

jscheuer1
05-15-2006, 04:23 PM
I had a version of the iframe shim laying around for another script. Here it is for DHTML tool tip:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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>
<!--[if gte IE 5.5]>
<!--[if lte IE 6]>
<iframe id="shim" src="" style="position:absolute;display:none;filter:progid:DXImageTransform.Microsoft.Chroma(Color='#ffffff');" scrolling="no" frameborder="0"></iframe>
<![endif]-->
<![endif]-->

<script type="text/javascript">
function shimit(obj){
if (typeof shim=='undefined')
return;
var shimobj=document.getElementById('shim').style;
shimobj.height=obj.offsetHeight+'px'
shimobj.width=obj.offsetWidth+'px'
var obj=obj.style
shimobj.left=obj.left
shimobj.top=obj.top
shimobj.zIndex=99
shimobj.display='block'
}

function noshim(){
if (typeof shim=='undefined')
return;
document.getElementById('shim').style.display='none';
}
</script>

</head>
<body>
<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
* Modified in http://www.dynamicdrive.com/forums to deal with IE
* select bug in IE5.5 through IE6 by jscheuer1
***********************************************/

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"
shimit(tipobj);
}
}

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

document.onmousemove=positiontip

</script>
<a href="http://www.yahoo.com" onMouseover="ddrivetip('Visit Yahoo.com')";
onMouseout="hideddrivetip()">Search Engine</a><br>&nbsp;<br>
<select>
<option>fgbjfgbha
<option>fgbjfgbha
<option>fgbjfgbha
<option>fgbjfgbha
</select>
</body>
</html>

meximex
05-16-2006, 08:30 AM
hi,
how can i put the tooltip into a layer?

would that help?

thx

meximex
05-16-2006, 08:31 AM
oh, thx for your reply.. i'll try that..