/    Sign up×
Community /Pin to ProfileBookmark

Could someone please help me to debug this javascript?

In FF the tooltip appears correctly next to the mouse pointer. In IE, the tooltip appears all over the place, often outside the display screen.

Thank you for taking an interest in my problem.

This is the .js file

[CODE]
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all || (navigator.userAgent.indexOf(‘Opera’) >= 0);
var ie4 = document.all;

var requester = null;

var offsetX = 0;
var offsetY = 20;
var toolTipSTYLE=””;
var CAPTION=’cap’;
var FG=’fg’;
var BG=’bg’;
var TEXTCOLOR=’tc’;
var CAPTIONCOLOR=’cc’;
var WIDTH=’tw’;
var HEIGHT=’th’;
var FONT=’font’;
var POSITIONY=’posy’;
var hideToolTip=true;
var cap, fg, bg, tc, cc, tw, th, font, posy = 0;

function initToolTips() {
if(ns4||ns6||ie4) {
if(ns4) toolTipSTYLE = document.toolTipLayer;
else if(ns6) toolTipSTYLE = document.getElementById(“toolTipLayer”).style;
else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
if(ns4);
else {
toolTipSTYLE.visibility = “visible”;
toolTipSTYLE.display = “none”;
}
}
}

function showLoadedData() {
var msg = ‘ERROR’;
if (requester.readyState == 4) {
if (requester.status == 200) {
msg = requester.responseText;
} else {
msg = “ERROR loading details”;
}
}
document.getElementById(‘infoDivTextRow’).innerHTML = msg;
return true;
}

function toolTipHide() {
if(ns4) {
toolTipSTYLE.visibility = “hidden”;
} else {
toolTipSTYLE.display = “none”;
var IfrRef = document.getElementById(‘DivShim’);
IfrRef.style.display = “none”;
}
}

function toolTip() {

if(arguments.length < 1) { // hide
if (hideToolTip == false) {
return;
}
if(ns4) {
toolTipSTYLE.visibility = “hidden”;
} else {
toolTipSTYLE.display = “none”;
var IfrRef = document.getElementById(‘DivShim’);
IfrRef.style.display = “none”;
}
} else { // show
e = arguments[0];
var msg = arguments[1];

var type = arguments[2];
fg = “#000000”;
bg = “#DDDDDD”;
tc = “#000000”;
cc= “#FFFFFF”;
font = “Verdana,Arial,Helvetica”;
tw = ”;
th = ”;
cap = ”;
posy = 0;
for(var i = 3; i < arguments.length; i+=2) {
switch (arguments[i]) {
case “cap”: cap = arguments[i+1]; break;
case “font”: font = arguments[i+1]; break;
case “fg”: fg = arguments[i+1]; break;
case “bg”: bg = arguments[i+1]; break;
case “tc”: tc = arguments[i+1]; break;
case “cc”: cc = arguments[i+1]; break;
case “tw”: tw = arguments[i+1]; break;
case “th”: th = arguments[i+1]; break;
case “posy”: posy = arguments[i+1]; break;
}
}
var imgdir = ‘images/’;
var content = ”;
titletext = ‘Details’;

content = ‘<div style=”width: ‘ + tw + ‘px;”>’ + msg + ‘</div>’;

if(ns4) {
toolTipSTYLE.document.write(content);
toolTipSTYLE.document.close();
toolTipSTYLE.visibility = “visible”;
} else if(ns6) {
moveToMouseLoc(e);
document.getElementById(“toolTipLayer”).innerHTML = content;
toolTipSTYLE.display=’block’;
} else if(ie4) {
moveToMouseLoc();

document.all(“toolTipLayer”).innerHTML=content;
toolTipSTYLE.display=’block’;
var IfrRef = document.getElementById(‘DivShim’);
var DivRef = document.getElementById(‘toolTipLayer’);
IfrRef.style.width = DivRef.offsetWidth;
IfrRef.style.height = DivRef.offsetHeight;
IfrRef.style.top = DivRef.style.top;
IfrRef.style.left = DivRef.style.left;
IfrRef.style.zIndex = DivRef.style.zIndex – 1;
IfrRef.style.display = “block”;
}
}
}

function moveToMouseLoc(e, tw, th) {
if(ns4||ns6) {
x = e.pageX;
y = e.pageY;
} else {
x = event.x + 200;
y = event.y + 120;
}

var left = x + 12;
var top = y – 20;

if(ns4||ns6) {
toolTipSTYLE.left = left + “px”;
toolTipSTYLE.top = top + “px”;
} else {
toolTipSTYLE.left = left;
toolTipSTYLE.top = top;
}

return true;
}
[/CODE]

This is the html code:

[CODE]
<div id=”toolTipLayer” style=”border: 2px solid rgb(0,0,128); padding: 7px; position: absolute; z-index: 5; visibility: visible; background-color: rgb(255, 255, 255); display: none;” onmouseover=”javascript:hideToolTip=false;” onmouseout=”javascript:hideToolTip=true; setTimeout(‘toolTip()’, 1500);”></div>
<script language=”JavaScript” src=”overlib.js” type=”text/javascript”></script>
<script type=”text/javascript”>
initToolTips();
</script>
[/CODE]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @zabran spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...