在网上搜了很多文章,试用了下。
结果:只有下面这能用
<script language="JavaScript">
<!--
if (window.Event)
document.captureEvents(Event.MOUSEUP);
function nocontextmenu()
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
function norightclick(e)
{
if (window.Event)
{
if (e.which == 2 || e.which == 3)
return false;
}
else
if (event.button == 2 || event.button == 3)
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
}
document.oncontextmenu = nocontextmenu; // for IE5+
document.onmousedown = norightclick; // for all others
//-->
</script>
其他的什么 oncontextmenu="window.event.returnvalue=false" <body oncontextmenu="return false"></body>都不行。
结果:只有下面这能用
<script language="JavaScript">
<!--
if (window.Event)
document.captureEvents(Event.MOUSEUP);
function nocontextmenu()
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
function norightclick(e)
{
if (window.Event)
{
if (e.which == 2 || e.which == 3)
return false;
}
else
if (event.button == 2 || event.button == 3)
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
}
document.oncontextmenu = nocontextmenu; // for IE5+
document.onmousedown = norightclick; // for all others
//-->
</script>
其他的什么 oncontextmenu="window.event.returnvalue=false" <body oncontextmenu="return false"></body>都不行。
本文提供了一段有效的JavaScript代码,用于禁止浏览器中的右键菜单弹出。该方法适用于多种浏览器环境,包括IE5+和其他现代浏览器。通过使用特定事件监听器实现,解决了其他方法无法正常工作的问题。
1717

被折叠的 条评论
为什么被折叠?



