Html & Script

마우스/키보드 막은 사이트 해제하기

페이지 정보

본문

기존에 거친마루님께서 올리신 글에 유사한 내용이 있으니 참고하세요.

드래그, 오른쪽 마우스 등을 막아놓은 사이트들이 많이 있습니다.
여러가지 이유가 있어서 막았겠지만, 여간 불편하지 않습니다.
그래서 필요시 해제할 수 있는 스크립트를 올립니다.

기존 글과의 차이점이라면 프레임이 있는 페이지인지 아닌지를 구분하는
부분이 다르다는 것, 그것 외에는 크게 다르지 않습니다.
보통 프레임의 개수를 셀때 top.frames.length 를 이용하는데, 이 경우
iframe 과 같은 의도하지 않은 태그들의 수치까지 포함되게 되어 원하는
작업을 정확히 할 수 없었습니다.
그래서 프레임셋에는 body 가 없다는 점을 이용해서 처리하였습니다.

function r(b)
{
    b.setAttribute('oncontextmenu','return true');
    b.setAttribute('onselectstart','return true');
    b.setAttribute('onkeydown','return true');
    b.setAttribute('ondragstart','return true');
}

function f(tf)
{
    if( tf.length < 1 ) {
        r( tf.document.body );
    } else {
        for( var i=0 ; i < tf.length ; i++ ) {
            f( tf.frames[i] );
        }
    }
}

var tb = document.all.tags( 'BODY' );
if( tb.length == 0 ) {
    f(top.frames);
} else {
    r(document.body);
}

그리고, 즐겨찾기에 추가하기 쉽게 한줄로 붙였습니다.
javascript:function r(b){b.setAttribute('oncontextmenu','return true');b.setAttribute('onselectstart','return true');b.setAttribute('onkeydown','return true');b.setAttribute('ondragstart','return true');}function f(tf){if(tf.length<1){r(tf.document.body);}else{for(var i=0;i<tf.length;i++){f(tf.frames[i]);}}}var tb=document.all.tags('BODY');if(tb.length==0){f(top.frames);}else r(document.body);

관련자료

등록된 댓글이 없습니다.
Today's proverb
당신은 남이 자기를 좋게 생각해 주기를 바라는가. 그러면 그것을 말하지 말라.