如何禁用右键?

来源:互联网 发布:周口网络销售招聘 编辑:程序博客网 时间:2024/05/21 10:20

方法一:
<SCRIPT language=javascript>
function click() {
if (event.button==2) {  //改成button==1为禁止左键
alert('版权所有,请勿复制!!')
}
}
document.onmousedown=click
</SCRIPT>

方法二:
<body oncontextmenu=self.event.returnValue=false>

方法三:

单击鼠标右键看看吧
<STYLE>
v/:*{behavior:url(#default#VML);}
</STYLE>
</HEAD>
<BODY oncontextmenu="return false">
<SCRIPT>
function document.onmousedown(){
if(document.readyState=="complete"&&event.button==2&&document.all.tags("OVAL").length<5&&event.x<window.document.body.offsetWidth-100&&event.y<window.document.body.offsetHeight-100&&event.srcElement.tagName!="INPUT"){
color1="rgb("+Math.round(Math.random() * 255)+","+Math.round(Math.random() * 255)+","+Math.round(Math.random() * 255)+")"
newvml="<v:oval strokecolor='"+color1+"' fillcolor='"+color1+"' style='filter:alpha(opacity=20);width:10;height:10;position:absolute;left:"+(event.x+document.body.scrollLeft)+";top:"+(event.y+document.body.scrollTop)+";'/>"
document.body.insertAdjacentHTML("beforeEnd",newvml)  
setTimeout("changoval()",10)
}}
function changoval(){
thelen=document.all.tags("OVAL").length
for(i=0;i<thelen;i++){         try{
var theobj=document.all.tags("OVAL")[i]
str1=parseInt(theobj.style.width)+1;
theobj.style.width=str1;
theobj.style.height=str1;
if(str1>200)theobj.removeNode()  
 }catch(e){}
}
if(thelen==0)clearTimeout(time1)
time1=setTimeout("changoval()",10)   
}
</SCRIPT>

 
原创粉丝点击