javascriptドラッグイベントの実現(IE 8対応)


Title function drag(obj) { var obj=document.getElementById(obj); obj.onmousedown=function (event) {// obj.setPointerCapture&&obj.releasePointerCapture();// ie8, obj event=event||window.event;//event var ol=event.clientX-obj.offsetLeft; var ot=event.clientY-obj.offsetTop; document.onmousemove=function (event) {// event=event||window.event; var left=event.clientX-ol; var top=event.clientY-ot; obj.style.left=left+"px"; obj.style.top=top+"px"; }; document.onmouseup=function () {//    document.onmousemove=null;//   document.onmouseup=null;// obj onmouseup   obj.releasePointerCapture&&obj.releasePointerCapture();// }; return false;// }; } window.onload=function () { drag("box1");// drag("box2"); } dal