JavaScript mouse event, right mouse button, popup div

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.