function Drag(id) { var trag =document.getElementById(flag); trag.onmousedown = function (e) { var page = { event: function (evt) { var ev = evt || window.event; return ev; }, pageX: function (evt) { var e = this.event(evt); return e.pageX || (e.clientX + document.body.scrollLeft - document.body.clientLeft); }, pageY: function (evt) { var e = this.event(evt); return e.pageY || (e.clientY + document.body.scrollTop - document.body.clientTop);
}, layerX: function (evt) { var e = this.event(evt); return e.layerX || e.offsetX; }, layerY: function (evt) { var e = this.event(evt); return e.layerY || e.offsetY; } } var x = page.layerX(e); var y = page.layerY(e); if (dv.setCapture) { dv.setCapture(); }else if (window.captureEvents) { window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP); } document.onmousemove = function (e) { var tx = page.pageX(e) - x; var ty = page.pageY(e) - y; dv.style.left = tx + "px"; dv.style.top = ty + "px"; } document.onmouseup = function () { if (dv.releaseCapture) { dv.releaseCapture(); } else if (window.releaseEvents) { window.releaseEvents(Event.MOUSEMOVE | Event.MOUSEUP); } document.onmousemove = null; document.onmouseup = null; } } }
新闻热点
疑难解答