Click to See Complete Forum and Search --> : Netscape Compatibility for Tooltip Script


Jona
06-15-2003, 09:15 PM
Yes, I'm back again. Khalid, I guess you never read any of the replies because you thought Dave had my question covered. He's being secretive. :D The code you posted made my tooltip script work for IE, but now NS, which you said was easy to make it work for too, is giving me problems. I got it as far as appearing the DIV, and working in IE, but as far as it moving in Netscape... No go. All right, so the page is at my testing page (http://geocities.com/god_loves_07/books.html), where you can view it for yourself, and the code I have is below (you'll notice commented out code that I used for testing, I left that in there on purpose):


var t, d, sX, sY, x, y;

function popup(txt, event){
d = document.getElementById("tooltip");
//d.style.top=event.pageY;
sX = (document.documentElement) ? document.documentElement.scrollLeft : 0; //window.innerWidth-event.pageX;
sY = (document.documentElement) ? document.documentElement.scrollTop : 0;
//window.innerHeight-event.pageY
if(navigator.appName!="Netscape"){t=event.srcElement; x=event.x+10+sX; y=event.y+10+sY;}
else{t=event.target; x=event.pageX+10+sX; y=event.pageY+10+sY;}
if(parseInt(navigator.appVersion)<4){return;}else{
d.style.top=y;
d.style.left=x;
d.style.visibility="visible";
d.innerHTML="<p align=justify style=width:240px>"+txt+"</p>";
t.title="";
return true;
} }

function stoppop(event){
d=document.getElementById("tooltip");
d.style.visibility="hidden";
d.innerHTML="";
return true;
}


In the popup() function, I have commented out d.style.top=event.pageY. I have created a small script that, onMouseMove of a DIV, moves another DIV the same place as the mouse (event) and it works with the afforementioned code. But when I tested the code with the afforementioned code, it only appears with the DIV at the top-right corner of the screen (where it is automatically because the position is set to absolute).

Thanks. :D

Jona

Khalid Ali
06-16-2003, 01:24 AM
Yep..just got back...and here is the solution...
take a look at the link below..now I don't care to write NS<5 compatible code n e more...the code will work in NS6+ browsers...

http://68.145.35.86/temp/jona/ToolTip_Jona.html

If the link is down...then try it again...it should be up 9 AM eastern time...

Let me know if thats not what you want..

Jona
06-16-2003, 09:37 AM
Yes, works! Thanks Khalid. By looking at the code, it just looks like I had a few minor things wrong with it. Did the event "variable" have anything to do with that? (E.g., function popup(e, txt) instead of popup(event, txt) ?)

Thanks, man, I've never dealt with DHTML very much... Not my most-often-worked-on project if you know what I mean. ;) I'm learning, though. Thanks.

Jona

Khalid Ali
06-16-2003, 10:05 AM
:D
Ya're most welcome...yest rememebr in the original post said there was very little diff to make the code work for NS?....:p
N E ways.. njoy..

Jona
06-16-2003, 10:06 AM
Well, learning never hurt no one. :p

Thanks again. :D

Jona