This article for everyone to share the JS solution Movebox Mobile problem, and cancel the picture default drag event related operations, for your reference, the specific content as follows
Html:
Js:
var Movebox;
Window.onload = function () {Movebox = document.getElementById ("Movebox");
Movebox.addeventlistener ("MouseDown", function (e) {if (E.button > 0) {fun2 ();
return false; } e.preventdefault && E.preventdefault ();
Ming elder brother: Remove picture drag response ruthless important gen.x = E.clientx;
GEN.Y = E.clienty;
gen._x = Movebox.offsetleft;
gen._y = Movebox.offsettop;
GEN.DX = gen.x-gen._x;
Gen.dy = gen.y-gen._y;
Document.addeventlistener ("MouseMove", Fun1,false);
Document.addeventlistener ("MouseUp", fun2, false);
}, False);
}; var fun1 = function (e) {Gen.
L = E.CLIENTX-GEN.DX; Gen.
T = E.clienty-gen.dy;
var timefun = function () {window.getselection (). Removeallranges (); if (Gen. L <) Gen.
L = 100; else if (Gen. L >) Gen.
L = 200; if (Gen. T < a) Gen.
T = 125; else if (Gen. T > 175) Gen.
T = 175; SETLT (Movebox, Gen. L, Gen.
T);
}; SetTimeout (Timefun, 2);
};
var fun2 = function () {Document.removeeventlistener ("MouseMove", fun1, false);
Document.removeeventlistener ("Mouseuo", fun2, false);
};
var Gen = {x:null, y:null, _x:null, _y:null, Dx:null, Dy:null, L:null, T:null,};
var setlt = function (DOM, L, T) {dom.style.left = L + "px";
Dom.style.top = T + "px"; };
Css:
body {
position:absolute;
margin:0;
padding:0;
}
#center {
position:absolute;
top:200px;
left:300px;
width:400px;
height:400px;
Background-color: #808080;
}
#black {
position:absolute;
width:400px;
height:400px;
z-index:80;
Background-color: #000;
opacity:0.6;
}
#bigimg {
z-index:50;
Position:absolute;
left:100px;
top:125px;
}
#movebox {
z-index:100;
Position:absolute;
width:100px;
height:100px;
left:150px;
top:150px;
Overflow:hidden;
Cursor:move;
Background-color: #ff6a00;
}
#moveimg {
position:absolute;
left:-50px;
top:-25px;
}
The above is the entire content of this article, I hope to help you learn.