网页禁用右键实现代码(JavaScript代码)
人气:0复制代码 代码如下:
<script language="javascript">
function disableRightClick(e)
{
var message = "右键禁用...";
if(!document.rightClickDisabled) // initialize
{
if(document.layers)
{
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = disableRightClick;
}
else document.oncontextmenu = disableRightClick;
return document.rightClickDisabled = true;
}
if(document.layers || (document.getElementById && !document.all))
{
if (e.which==2||e.which==3)
{
alert(message);
return false;
}
}
else
{
alert(message);
return false;
}
}
disableRightClick();
</script>
使用方法,直接复制代码放到<head></head>中即可。
加载全部内容