Transparent window (div) is not bounding mouse position and isjumping around in IE.

T

Thomas 'PointedEars' Lahn

Terry said:
I got it working now, it turns out that I was calculating the position
of the mouse incorrectly for IE.

http://theamazing.onlinewebshop.net/light/

I recommend you improve your overall programming style. For example, why

var imageL = imageT = imageB = imageR = 0;

but

var l = null;
var t = null;
var trans = null;
var r = null;
var rest = null;

(the latter form is the correct one, of course, as anything but `imageL' was
_not_ declared)?

Why not

var large = document.getElementById("large");
large.style.left = -(shiftleft * 4) + 'px';
large.style.top = -(shifttop * 4) + 'px';

and

var inside = document.getElementById("inside");
inside.style.borderLeftWidth = lborder + 'px';
inside.style.borderRightWidth = rborder + 'px';
inside.style.borderTopWidth = tborder + 'px';
inside.style.borderBottomWidth = bborder + 'px';
inside.style.visibility = 'visible';
document.getElementById("light").style.visibility = 'visible';

instead of the far less efficient and much harder to maintain

document.getElementById("large").style.left = -(shiftleft*4) + 'px';
document.getElementById("large").style.top = -(shifttop*4) + 'px';

and

document.getElementById("inside").style.borderLeftWidth = lborder + 'px';
document.getElementById("inside").style.borderRightWidth = rborder + 'px';
document.getElementById("inside").style.borderTopWidth = tborder + 'px';
document.getElementById("inside").style.borderBottomWidth = bborder + 'px';
document.getElementById("inside").style.visibility = 'visible';
document.getElementById("light").style.visibility = 'visible';

(the missing runtime feature tests aside)? Why not

if (!e) e = window.event;
if (!e)
{
// ...
}

instead of

var evt = e || window.event;
// no feature test here

?

That said, why not

<div id="opaque" ...
onmousemove="if (typeof event != "undefined") theMousemove(event);"
onmouseout="if (typeof event != "undefined") theMouseoutl(event);">

which AFAIK removes the need for a the aforementioned test instead of the
less efficient and more error-prone

document.getElementById("opaque").onmousemove = theMousemove;
document.getElementById("opaque").onmouseout = theMouseoutl;

? Why

if (obj.offsetParent) {
while (obj.offsetParent) {
// ...
}
}

where

while (obj.offsetParent)
{
// ...
}

would have sufficed? And I could go on.


HTH

PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,147
Messages
2,570,835
Members
47,382
Latest member
MichaleStr

Latest Threads

Top