더 이상 고민하지 않고 코드만 게시해 드리겠습니다.
코드는 다음과 같습니다.
<script language="JavaScript"> <!-- //js禁用某些键的代码 //www.jb51.net function key(){ if(event.shiftKey){ window.close();} //禁止Shift if(event.altKey){ window.close();} //禁止Alt if(event.ctrlKey){ window.close();} //禁止Ctrl return false;} document.onkeydown=key; if (window.Event) document.captureEvents(Event.MOUSEUP); function nocontextmenu(){ event.cancelBubble = true event.returnValue = false; return false;} function norightclick(e){ if (window.Event){ if (e.which == 2 || e.which == 3) return false;} else if (event.button == 2 || event.button == 3){ event.cancelBubble = true event.returnValue = false; return false;} } //禁右键 document.oncontextmenu = nocontextmenu; // for IE5+ document.onmou<a href="http://www.jb51.net/article/1141.html" target="_blank" class="infotextkey">sed</a>own = norightclick; // for all others //--> </script>
no |
PS: 뒤로가기, 새로고침, 닫기를 방지하는 JS 솔루션
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head> <title> New Document </title> </head> <script language="javascript"> function RunOnBeforeUnload() {window.onbeforeunload = function(){ return '将丢失未保存的数据!'; } } </script> <body onload="RunOnBeforeUnload()"> 刷新,关闭,后退,F5 测试 </body> </html>
테스트 결과:
IE6.0, FireFox, Chrome 통과