This code works in firefox:
document.oncontextmenu=disableclick;
function disableclick(event)
{
event.preventDefault();
alert("Context Menu Disabled");
return false;
}
http://jsfiddle.net/zumk5cta/1/
Update
contextmenu
event won't work for disabled elements in firefox, it's a firefox behavior as explained well here
As a solution to your problem, I picked up the idea given by @Endy E in his response here:
html
<span class="inputWrapper">
<input type="text" disabled />
<div class="mouseEventTarget"></div>
</span>
css
.inputWrapper{
position:relative;
}
.mouseEventTarget{
position:absolute;
left:0;
right:0;
top:0;
bottom:0;
cursor: text
}
javascript
$(document).on('contextmenu', 'input:disabled + .mouseEventTarget',function(e){
return false;
});
fiddle