捕捉页面刷新or关闭、禁止鼠标右键及禁止复制

来源:互联网 发布:福建广电网络维修电话 编辑:程序博客网 时间:2024/05/21 15:09
<script type="text/javascript" language="javascript">//onbeforeunload是先刷新再关闭,onunload相反window.onbeforeunload = function fun()   {     var n = window.event.screenX - window.screenLeft;     var b = n > document.documentElement.scrollWidth-20;     if(b && window.event.clientY < 0 || window.event.altKey)  {   alert('当前是关闭页面操作!');  }  else  {alert('当前是刷新页面操作!');    }    }   window.clipboardData.setData('text','需要复制的值');--剪切板复制document.oncontextmenu=new Function('event.returnValue=true;');--禁用鼠标右键document.onselectstart=new Function('event.returnValue=false;');--禁止复制</script>