我有以下短代码
<body oncontextmenu="return false">
<p class="info">
Books are the world of information. As said the books are the best friends. A wise
man always has a library of several books</p>
<ul id="contextmenu">
........
JS:
$('.info').mousedown(function (event) {
if (event.button == 2) {
$('#contextmenu').show();
}
}
当我右键单击.info时,我希望浏览器的上下文菜单不会与我们的上下文菜单一起显示为默认值。
oncontextmenu="return false"
不起作用
答案 0 :(得分:2)
将此javascript放入您的头标记
<script>
document.oncontextmenu = function(e){
return false;
}
</script>
以下内容也适用于我
<html oncontextmenu="return false">