: :
<! doctype html> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html ؛ charset = utf-8" /> <title> 鼠标拖动和拖拽的鼠标指针特效 </title> <style> #box {width: 100px ؛ الارتفاع: 100px ؛ الخلفية:#966 ؛ الموضع: المطلق ؛ اليسار: 100px ؛ أعلى: 100px ؛ cursor {العرض: math.max (document.documentElement.clientwidth ، document.documentElement.ScrollWidth) ، الارتفاع: Math.Max (document.documentElement.clientheight ، document.documentelement.scrollheight)} ؛ الحالة x> maxnum: x = maxnum ؛ break ؛ الافتراضي: x ؛ } إرجاع x ؛ } box.style.left = '100px'box.style.top =' 100px'box.onmousedown = function (e) {var e = e || window.event ؛ var maxl = getViewPort (). width-100 ، maxt = getViewPort (). height-100 ؛ this.startl = parseint (this.style.left) ؛ this.startt = parseint (this.style.top) ؛ //alert(e.clientx) this.startx = e.clientx ؛ this.starty = e.clienty ؛ // ALERT (maxl+':'+maxt+':'+l+':'+t) doc.onmousemove = function (e) {posxy (e ، 0،0 ، maxl ، maxt) ؛ } ؛ doc.onmouseup = function () {doc.onmousemove = null ؛ doc.onmouseup = null ؛ } ؛ return false ؛} وظيفة posxy (e ، minl ، mint ، maxl ، maxt) {var e = e || window.event ؛ var x = box.startl- (box.startx-e.clientx) ؛ var y = box.startt- (box.starty-e.clienty) ؛ box.style.left = comparenum (x ، minl ، maxl)+'px' box.style.top = comparenum (y ، mint ، maxt)+'px'} </script> </body> </html>[Ctrl+A 全选 注: 如需引入外部 JS 需刷新才能执行]