개발하는 과정에서는 다 열어두고 사용하되
마지막 배포 전 모든 것을 막을 필요가 있다.
코딩 소스는 부끄러우니깐
# [javascript] 마우스 우클릭 방지 / 개발자도구(F12) 방지
1. 아래의 소스코드를 <head> 태그 사이에 넣는다.
# source code 01
<head>
...
<script type="text/javascript">
// F12 버튼 방지
$(document).ready(function(){
$(document).bind('keydown',function(e){
if ( e.keyCode == 123 /* F12 */) {
e.preventDefault();
e.returnValue = false;
}
});
});
// 우측 클릭 방지
document.onmousedown=disableclick;
status="Right click is not available.";
function disableclick(event){
if (event.button==2) {
alert(status);
return false;
}
}
</script>
...
</head>
2. <body> 안에 아래의 태그를 입력한다.
- oncontextmenu='return false' - 우클릭방지
- onselectstart='return false' - 블럭선택방지
- ondragstart='return false' - 드래그방지
<body oncontextmenu='return false' onselectstart='return false' ondragstart='return false'>
P.S. 키보드 버튼 식별코드
출처: https://server-engineer.tistory.com/563 [HelloWorld]
'JavaScript' 카테고리의 다른 글
자바스크립트를 이용한 동적 폼(form) 생성 및 post 요청 (0) | 2020.02.12 |
---|---|
reload(), 페이지 다시 읽기, 새로고침 (0) | 2020.02.04 |
자바스크립트 Array Sort() 정리 사이트 (0) | 2019.06.26 |
댓글