Eric Krock
Senior Product Manager
Netscape Communicator
... but first take the pledge! Remember:
<div id="myElement" onmousedown="beginDrag(event);" style="position: absolute; left: 150px; top: 150px; width: 100px; background-color: blue;"> Test one two three </div>
function beginDrag(e) { dump("drag start\n"); window.lastX=e.clientX; window.lastY=e.clientY; window.onmousemove=doDrag; window.onmouseup=endDrag; } function endDrag(e) { dump("drag end\n"); window.onmousemove=null; }
function doDrag(e) { dump("dragging\n"); var difX = e.clientX-window.lastX; var difY = e.clientY-window.lastY; var newX = parseInt(document.getElementById ("myElement").style.left)+difX+"px"; var newY = parseInt(document.getElementById ("myElement").style.top)+difY+"px"; document.getElementById ("myElement").style.left=newX; document.getElementById ("myElement").style.top=newY; window.lastX = e.clientX; window.lastY = e.clientY; dump("dragging comp\n"); }
function hlt(event) { this.style.backgroundColor = "rgb(255, 255, 204)"; this.style.textDecoration = "underline"; } function dlt(event) { this.style.backgroundColor = "transparent"; this.style.textDecoration = "none"; }
function depress() { this.style.position="relative"; this.style.left="3px;" this.style.top="3px;" this.style.color="#660000"; } function undepress() { this.style.position="relative"; this.style.left="0px;" this.style.top="0px;" this.style.color="#000099"; }