1

주제: 자바스크립트로 드래그, 우클릭 금지 시...

아래 코드와 같이 자바스크립트로 드래그, 우클릭을 금지시켰는데
input이나 textarea에서도 드래그가 금지 되어버리는데;
input, textarea에서는 드래그를 허용시킬수 있는 방법없을까요?


//<![CDATA[

// 드래그, 우클릭 금지 시키기 //
var omitformtags=["input", "textarea", "select"]
omitformtags=omitformtags.join("|")
function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}
function reEnable(){
return true
}
if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}

document.oncontextmenu = function() {return false;};
document.onselectstart = function() {return false;};
document.ondragstart = function() {return false;};

// 접었다 폈다 하기 //
function showhide(obj) {
    var el = document.getElementById(obj);
    if ( el.style.display != 'none' ) {
        el.style.display = 'none';
    } else {
        el.style.display = 'inline';
    }
};

//]]>

2

답글: 자바스크립트로 드래그, 우클릭 금지 시...

저도 오늘 이 생각을 하다가 네이버 지식인에서 해답을 찾았답니다.
3년이나 지난 글이지만 같은 의문을 갖고서 이 글을 읽게 되실 미래의 누군가를 위해 댓글을 쓰겠습니다. ㅋㅋ
body에 우클릭 드래그 금지 속성을 넣지 말고요,
article의 본문 부분(desc) 이 싸여 있는 div에다가
<div align='justify' oncontextmenu='return false' ondragstart='return false' onselectstart='return false'>
이렇게 속성을 주시면
textarea에서는 드래그가 된답니다!!
이거 찾아내서 행복해요 꺄아 > <