HTML Mouse Right-click menu code

Source: Internet
Author: User

<! DOCTYPE html>
 
 
    1. I've seen a lot of code on the Internet before, but there's a bug that counts a lot of bugs, but I'm going to say it here. Mouse Right click on the event mouse release after the execution, because of the personal operating habits, when the right-click on the
    2. The 0*0 position of the button is also executed right button, so that the top shielding why also display the default browser menu, then we just need to display the elements of the mouse right button to shield off will not, welcome to reprint This code, thank you!
        $ ("#btn"). Bind ("ContextMenu", function () {            return false;        })        $ ("#img"). MouseDown (function (e) {            if (E.which = = 3)            {                //Gets the x-axis of the mouse                var x = E.pagex;                Gets the y-axis of the mouse                var y = e.pagey;                The position of the menu element we set is moved to the current right-click position of the mouse and displayed as                $ ("#btn"). CSS ({' top ': Y + ' px ', ' left ': x + ' px ', ' Display ': ' block ', ' position ': ' Absolute '})}    ) </script></body>

  

HTML Mouse Right-click menu code

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.