<script> var iscopy=0; document.body.oncopy = function (){ var url = window.location.href; if (iscopy==0){ // my_pays(url,site) console.log('禁止复制'); }else { if (iscopy==1){ return true; } } return false; } window.onkeydown = function(e){ if(e.keyCode == 83&&e.ctrlKey){ //ctrl+s console.log('禁止保存'); return false; } if(e.keyCode == 67&&e.ctrlKey){ // ctrl+c var url = window.location.href; if (iscopy==0){ //my_pays(url,site) console.log('禁止复制'); }else { if (iscopy==1){ return true; } } return false; } if(e.keyCode == 88&&e.ctrlKey){ //ctrl+x var url = window.location.href; if (iscopy==0){ //my_pays(url,site) console.log('禁止复制剪切'); }else { if (iscopy==1){ return true; } } return false; } if(e.keyCode == 85&&e.ctrlKey){ //ctrl+u console.log('禁止查看源码'); return false; } if(e.keyCode == 123){ //f12 console.log('禁止查看元素'); return false; } if(e.keyCode == 80&&e.ctrlKey){ //ctrl+p console.log('禁止打印'); return false; } } </script>
解封的办法也很简单,鼠标在地址栏上点一下,然后再用快捷键,就跳出了document的限制。