当前位置:编程学习 > JS >>

完全禁用鼠标右键的JS代码

完全禁用鼠标右键的JS代码,FX、Alt、Ctrl、Shift等键都将彻底失去作用,并且也禁止了鼠标文本选择,很多人喜欢用这种功能,实际上这种功能会给浏览网页的朋友带来不便,而且对高手来说也没有多大用处。
答案:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>禁止鼠标右键</title>
</head>
<script>
function onKeyDown()
{
	if ((event.keyCode==116)||(window.event.ctrlKey)||(window.event.shiftKey)||(event.keyCode==122))
	{
	event.keyCode=0;
	event.returnValue=false;
	}
}
</script>

<script>
function yxl() { 
if(window.event.altKey) 
{
window.event.returnValue=false;
}
}
document.onkeydown=yxl 
</script> 
<body  onkeydown="onKeyDown()" oncontextmenu="return false" onselectstart="return false" ondragstart="return false"  >
<p>右键不管用了呢?你鼠标坏了吧?</p>
</body>
</html>

上一个:漂浮广告JS代码,图片飘动特效
下一个:漂亮的CSS滚动条代码

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,