san*_*kar 1 html javascript css jquery
如何在禁用文本框时在jquery中禁用此下下文菜单.我的右键单击禁用功能在除Firefox之外的所有浏览器中都正常工作.
注意:启用文本框后,右键单击禁用功能在所有浏览器中都能正常工作.请在此处提供帮助.
我在我的body标签中尝试了以下代码.但它不适用于Firefox
oncontextmenu="return false;"
Run Code Online (Sandbox Code Playgroud)

此代码适用于Firefox:
document.oncontextmenu=disableclick;
function disableclick(event)
{
event.preventDefault();
alert("Context Menu Disabled");
return false;
}
Run Code Online (Sandbox Code Playgroud)
http://jsfiddle.net/zumk5cta/1/
更新
contextmenu事件将不会在Firefox禁用的元素工作,这是一个Firefox的行为很好地解释这里
HTML
<span class="inputWrapper">
<input type="text" disabled />
<div class="mouseEventTarget"></div>
</span>
Run Code Online (Sandbox Code Playgroud)
CSS
.inputWrapper{
position:relative;
}
.mouseEventTarget{
position:absolute;
left:0;
right:0;
top:0;
bottom:0;
cursor: text
}
Run Code Online (Sandbox Code Playgroud)
JavaScript的
$(document).on('contextmenu', 'input:disabled + .mouseEventTarget',function(e){
return false;
});
Run Code Online (Sandbox Code Playgroud)