JavaScript mouse event, right click the mouse and pop up a simple instance of the div
document.oncontextmenu = function(){return false}; //Forbid the right mouse button menu to display var res = document.getElementById('box'); //Find the div document.body.onmouseup = function(e){ //Click in the body to trigger the event 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 passed parameters console.log(e.offsetY); //Print out the Y-axis coordinate console.log(e.offsetX); //Print out the X-axis coordinates of the mouse click res.style.top = e.offsetY+'px'; //Position the Y-axis for the div when clicking the mouse res.style.left = e.offsetX+'px'; //Position the X-axis for the div when clicking the mouse res.style.display = 'block'; //Show the div box}else{ res.style.display = 'none'; //Otherwise, the div box will not be displayed} }The above JavaScript mouse event, right-clicking the mouse, and the simple example of the pop-up div is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.