Document.oncontextmenu =function(){return false};//Disable the right mouse button menu display varres = document.getElementById (' box ');//find the div with the ID boxDocument.body.onmouseup =function(e) {//Click on the trigger event in the body. if(e.button===2) {//if button=1 (left mouse button), button=2 (right mouse button), button=0 (middle mouse button)Console.log (e);//print out the parameters passed inConsole.log (e.offsety);//Print the y-axis coordinates of the mouse clickConsole.log (E.OFFSETX);//Prints the x-axis coordinates of the mouse clickRes.style.top = e.offsety+ ' px ';//position the y-axis for div when mouse clicksRes.style.left = e.offsetx+ ' px ';//positioning the X-axis for div when mouse clicksRes.style.display = ' block ';//Show Div Box}Else{Res.style.display= ' None ';//Otherwise, the div box is not displayed } }
JavaScript mouse event, right mouse button, popup div