vegeta
07-14-2003, 09:59 PM
I want to make my layer moving script (for IE) compatible with Mozilla, but I can't get it to work properly. My layer moves, but very shaky. It seems to me that there is a problem with the onmouseup event ... After several times clicking and draging the layer it seems to work a bit better, but not yet the way it has to. This is what I've got :
thx in advance
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> testMZ </title>
<STYLE>
.drag
{
CURSOR: hand; POSITION: relative
}
</STYLE>
<SCRIPT>
var dragapproved=false
var eventTarget
var layerY
var eventY
function move(capturedEvent)
{
if (dragapproved == true)
{
eventTarget.style.top = layerY+capturedEvent.layerY-eventY
}
}
function drags(capturedEvent)
{
if (document.getElementById && capturedEvent.target.className == "drag")
{
dragapproved=true
eventTarget=capturedEvent.target
layerY=eventTarget.y
eventY=capturedEvent.layerY
window.onmousemove=move
}
}
document.onmousedown = drags
document.onmouseup = new Function("dragapproved=false")
</SCRIPT>
</head>
<body>
<DIV style="position:absolute; left:300px; top:37px; visibility:visible;"><IMG id="scrollUnit" name="scrollUnit" class="drag" src="item_scrollunit.gif"></DIV>
</body>
</html>
thx in advance
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> testMZ </title>
<STYLE>
.drag
{
CURSOR: hand; POSITION: relative
}
</STYLE>
<SCRIPT>
var dragapproved=false
var eventTarget
var layerY
var eventY
function move(capturedEvent)
{
if (dragapproved == true)
{
eventTarget.style.top = layerY+capturedEvent.layerY-eventY
}
}
function drags(capturedEvent)
{
if (document.getElementById && capturedEvent.target.className == "drag")
{
dragapproved=true
eventTarget=capturedEvent.target
layerY=eventTarget.y
eventY=capturedEvent.layerY
window.onmousemove=move
}
}
document.onmousedown = drags
document.onmouseup = new Function("dragapproved=false")
</SCRIPT>
</head>
<body>
<DIV style="position:absolute; left:300px; top:37px; visibility:visible;"><IMG id="scrollUnit" name="scrollUnit" class="drag" src="item_scrollunit.gif"></DIV>
</body>
</html>