拖拽一定要去除默认行为!!
var _Mover=function(dom,parent) { var _s = $(dom), cc = false, l, t , S = $(parent) || _s; _s.css("cursor", "move"); _s.mousedown(function (e) { var e = e || event, ele = e.target || e.srcElement; if (ele.nodeName.toLocaleLowerCase() == "a") return; l = e.pageX - S.offset().left; t = e.pageY - S.offset().top; $(document).mousemove(function (e) { $(this).css("cursor", "move"); var e = e || event, x = e.pageX, y = e.pageY, L = x - l, T = y - t; if (L < 0) L = 0; else if (L > $(window).width() - S.outerWidth()) L = $(window).width() - S.outerWidth(); if (T < $(window).scrollTop()) T = $(window).scrollTop(); else if (T > ($(window).scrollTop() + $(window).height() - S.outerHeight())) T = $(window).scrollTop() + $(window).height() - S.outerHeight(); S.css({ "left": L, "top": T, "margin": 0 }); }); $(document).mouseup(function () { $(this).css("cursor", "default"); $(document).unbind("mousemove"); $(document).unbind("mouseup"); }); stop(e); }) function stop(e) { var e = e || event; //if (e.stopPropagation) e.stopPropagation(); //else e.cancelBubble = true; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; }