Reputation: 385
In a kiosk environment, where there is no keyboard, and only a device that the browsers sees as a 2 button mouse, I need access to the right mouse click. This is a custom application running in a browser against file://.... with no Internet access behind airport security.
The left button will increase by 1 a totals field. The intent for the right mouse button is to decrease by 1 the same totals field. There are dozens of such fields on the page.
If I turn off the context menu, I still don't get a click event on right mouse click, even though the Mozilla Developer site documents what I'm supposed to get. How can I gain access to the click event on right click?
I can't use double click on the left to signal the negative because we expect users to rapidly left click to run up totals per field. Having left double click mean negative wouldn't work.
Upvotes: 2
Views: 214
Reputation: 1870
Set context to return false on the body, then add handlers to the elements you wish to handle. Bubbling.
<body oncontextmenu='return false' style='margin: 0px; width: 100%; height: 100%; position: absolute;'>
<div style='width: 64px; height: 64px; background: rgb(44, 188, 44); position: absolute;' oncontextmenu='alert("Click!");'>
</body>
Upvotes: 0
Reputation: 2488
Use the oncontextmenu
event and the click
event. Link to jsFiddle: http://jsfiddle.net/EgL3R/
$('.area').click(function () {
increment(this, 1);
}).bind('contextmenu', function () {
increment(this, -1);
return false;
});
Have fun :)
Upvotes: 1
Reputation: 817
<div oncontextmenu="javascript:alert('success!');return false;">
Lorem Ipsum
</div>
If you do not return false it will also open the normal right click menu
If you right click on the div it will perform the function you give it
Upvotes: 1