禁止鼠标右键的代码(转)-飞外

 1 SCRIPT language=javascript  2 !-- 3 if (window.Event) 4 document.captureEvents(Event.MOUSEUP); 5 function nocontextmenu(){ 6 event.cancelBubble = true 7 event.returnValue = false; 8 return false;10 function norightclick(e){11 if (window.Event){12 if (e.which == 2 || e.which == 3)13 return false;15 else16 if (event.button == 2 || event.button == 3){17 event.cancelBubble = true18 event.returnValue = false;19 return false;22 document.oncontextmenu = nocontextmenu; // for IE5+23 document.onmousedown = norightclick; // for all others24 //-- 25 /SCRIPT 

3.禁止选中代码

1 SCRIPT language=JavaScript 2 document.oncontextmenu=new Function("event.returnValue=false;");3 document.onselectstart=new Function("event.returnValue=false;");4 /SCRIPT 

 1 script   2 var omitformtags=["input", "textarea", "select"] 3 omitformtagsomitformtags=omitformtags.join("|") 4 function disableselect(e){ 5 if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1) 6 return false 8 function reEnable(){ 9 return true11 if (typeof document.onselectstart!="undefined")12 document.onselectstart=new Function ("return false")13 else{14 document.onmousedown=disableselect15 document.onmouseup=reEnable17 /script 

7.禁止网页另存为

1 noscript iframe src="/*.html /iframe /noscript 

8.禁止选择文本

 1 script   3 var omitformtags=["input", "textarea", "select"] 5 omitformtagsomitformtags=omitformtags.join("|") 7 function disableselect(e){ 8 if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1) 9 return false12 function reEnable(){13 return true16 if (typeof document.onselectstart!="undefined")17 document.onselectstart=new Function ("return false")18 else{19 document.onmousedown=disableselect20 document.onmouseup=reEnable22 /script 

9.禁用右键

1 script 2 function stop(){3 return false;5 document.oncontextmenu=stop;6 /script 

10.真正的鼠标右键屏蔽

 1 script language="JavaScript"  2 !-- 4 if (window.Event) 5 document.captureEvents(Event.MOUSEUP); 7 function nocontextmenu() 9 event.cancelBubble = true10 event.returnValue = false;12 return false;15 function norightclick(e)17 if (window.Event)19 if (e.which == 2 || e.which == 3)20 return false;22 else23 if (event.button == 2 || event.button == 3)25 event.cancelBubble = true26 event.returnValue = false;27 return false;32 document.oncontextmenu = nocontextmenu; // for IE5+33 document.onmousedown = norightclick; // for all others34 //-- 35 /script