用js实现屏蔽F12、鼠标右击、鼠标左击

function window.onhelp(){return false} //屏蔽F1帮助

document.onkeydown = function(){

  if(window.event && window.event.keyCode == 113) { window.event.keyCode = 505; }

  if(window.event && window.event.keyCode == 114) { window.event.keyCode = 505; }

  if(window.event && window.event.keyCode == 115) { window.event.keyCode = 505; }

  if(window.event && window.event.keyCode == 116) { window.event.keyCode = 505; }

  if(window.event && window.event.keyCode == 117) { window.event.keyCode = 505; }

  if(window.event && window.event.keyCode == 118) { window.event.keyCode = 505; }

  if(window.event && window.event.keyCode == 119) { window.event.keyCode = 505; }

  if(window.event && window.event.keyCode == 120) { window.event.keyCode = 505; }

  if(window.event && window.event.keyCode == 121) { window.event.keyCode = 505; }

  if(window.event && window.event.keyCode == 122) { window.event.keyCode = 505; }

  if(window.event && window.event.keyCode == 123) { alert("F12被禁用"); event.keyCode=0; event.returnValue=false; }

  if(window.event && window.event.keyCode == 13) { window.event.keyCode = 505; }

  if(window.event && window.event.keyCode == 8) { alert(str+"\n请使用Del键进行字符的删除操作!"); window.event.returnValue=false; }

  if(window.event && window.event.keyCode == 505){   alert(str) window.event.returnValue=false; }

}

document.onmousedown=function(oEvent){

  if(window.event) oEvent=window.event;

  if(oEvent.button==2) alert("鼠标右键不可用");

  if(oEvent.button==1) alert("鼠标左键不可用");

}

posted @ 2017-02-20 14:07  王鹏coder  阅读(272)  评论(0编辑  收藏  举报