五年级阅读短文:做网页都有什么方法来禁用右键啊?

来源:百度文库 编辑:高考问答 时间:2024/03/29 16:44:47
本人想做些网页,做个禁用右键的功能. 不知道都有什么方法可以实现.高手们请帮忙.最好能给出代码.谢谢.

最简单的代码:
<body oncontextmenu="return false">

禁用右键

<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>

禁用右键代码

将以下代码加到〈head〉与〈/head〉之间

<script language="JavaScript">
document.oncontextmenu=new Function("event.returnValue=false;");
document.onselectstart=new Function("event.returnValue=false;");
</script>

最简单的代码:
<body oncontextmenu="return false">

同意