开发者

Right-click on one image, disable clicks on the others

开发者 https://www.devze.com 2023-01-12 19:25 出处:网络
I have one page filled with images (image1, image2, image3).What I wou开发者_高级运维ld like to happen is:

I have one page filled with images (image1, image2, image3). What I wou开发者_高级运维ld like to happen is:

While a right-click is active on image1... image2 and image2 are disabled to receive any left-clicks or right-clicks until I end the right-click on image1. Does anyone know how to achieve this in javascript? Thank you!


Here is possible solution if you are using jQuery.

  1. Get the plugin from http://abeautifulsite.net/blog/2008/05/jquery-right-click-plugin/
  2. You code will be something like:

    $(document).ready( function() {
    
        // Capture right click
        $("#imgX").rightClick( function(e) {
    
            $('body').click(function () {
                return false;
            });
    
    
        });
    
     });
    

Actually above wont work. Is your right click menu custom or browser default? If it is custom then you can use the above as guidelines on how to do it. Not sure what you are trying to achieve. Normally, when you right click on an image, and the context menu is active, if you click on something else, the context menu disappears so technically, what you want is already being achieved.

0

精彩评论

暂无评论...
验证码 换一张
取 消