站长资源
中国站长网站

JS禁止用户操作整理如右键、全选、复制另存为等

禁用右键菜单

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

禁止选取的内容

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

禁用复制

document.oncopy = function(){
    return false;
}

以上三大常用禁止方法,可以直接写在body中,如

<body oncontextmenu = "return false" ></body>

<body onselectstart = "return false" ></body>

<body oncopy = "return false" ></body>

禁用鼠标滚轮

document.onmousedown = function(e){
    if ( e.which == 2 ){// 鼠标滚轮的按下,滚动不触发
        return false;
    }
    if( e.which==3 ){// 鼠标右键
        return false;
    }
}

禁用键盘中的ctrl、alt、shift

document.onkeydown = function(){
    if( event.ctrlKey ){
        return false;
    }
    if ( event.altKey ){
        return false;
    }
    if ( event.shiftKey ){
        return false;
    }
}

禁止网页另存为,在body下面增加如下代码

<noscript> 
  <iframe src="*.htm"></iframe> 
</noscript>

本文出处:来自互联网信息共享,请勿相信收费信息站长资源 » JS禁止用户操作整理如右键、全选、复制另存为等

评论 抢沙发

评论前必须登录!