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.
- Get the plugin from http://abeautifulsite.net/blog/2008/05/jquery-right-click-plugin/
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.
精彩评论