- <html>
- <body>
- <div id="div1" style="POSITION: absolute; LEFT: 0px; TOP: 0px; WIDTH: 356px;HEIGHT: 284px; BACKGROUND-COLOR: silver;"
- onmousedown="down()" onmousemove="move()" onmouseup="up()"></div>
- <script>
- var isdown = false
- var beginx,beginy
- function down() {
- isdown = true;
- }
- function move() {
- if (isdown){
- var endx = event.clientX;
- var endy = event.clientY;
- div1.style.left = parseInt( div1.style.left ) + endx-beginx;
- div1.style.top = parseInt( div1.style.top ) + endy-beginy;
- }
- beginx = event.clientX;
- beginy = event.clientY;
- }
- function up() {
- isdown = false;
- }
- </script>
- </body>
- </html>