컨트롤 쉬프트 i 도 방지해야하겠지~?
# [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://thinkandthing.tistory.com/category/JavaScript
1. <head> tag에 적용하기
아래의 소스코드를 <head> 태그 사이에 넣는다.
<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> tag에 적용하기
<body oncontextmenu='return false' onselectstart='return false' ondragstart='return false'>
a) oncontextmenu='return false': 우클릭 방지
b) onselectstart='return false': 블록선택 방지
c) ondragstart='return false': 드래그 방지
💡 키보드 버튼 식별코드
출처: https://server-engineer.tistory.com/563 [HelloWorld]
'개발자 관련 공부 > 멀티캠퍼스' 카테고리의 다른 글
[a태그] 밑줄 없애기, 점선으로 바꾸기, 색깔 바꾸기, 굵기 바꾸기 등 (0) | 2022.03.04 |
---|---|
[Tiles] 한 페이지에 두개의 페이지 화면을 띄우는 방법 (0) | 2022.03.04 |
[세미프로젝트중] 이미지 대체 사용팁. placehold.co (0) | 2022.02.28 |
[인증, 감정 API] CAPTCHA 이미지, 음성, 감정분석 (0) | 2022.02.21 |
[API]연습 (0) | 2022.02.18 |
댓글