网页防扒技术合集防止CSS和页面被偷

前言

很多时候我们辛辛苦苦写的代码和页面被人偷去,今天就给大家分享一下网站页面防止被扒站的代码合集

代码

1.禁用浏览器右键菜单

2.监听键盘事件

document.onkeydown = document.onkeyup = document.onkeypress = function(event) {
var e = event || window.event || arguments.callee.caller.arguments[0];
if (e && e.keyCode == 123) {
window.location = 'about: blank';
e.returnValue = false;
return (false);
}
}
document.onkeydown = document.onkeyup = document.onkeypress = function(event) {
    var e = event || window.event || arguments.callee.caller.arguments[0];
    if (e && e.keyCode == 123) {
            window.location = 'about: blank';
            e.returnValue = false;
            return (false);
    }
}
document.onkeydown = document.onkeyup = document.onkeypress = function(event) { var e = event || window.event || arguments.callee.caller.arguments[0]; if (e && e.keyCode == 123) { window.location = 'about: blank'; e.returnValue = false; return (false); } }

3.检测控制台

function mAlert() {
var fn = function () {};
fn.toString = function () {
window.location = 'about: blank';
console.log("呵呵");
}
console.log("%c", fn);//请不要删除这行
};mAlert();
function mAlert() {
    var fn = function () {};
    fn.toString = function () {
        window.location = 'about: blank';
        console.log("呵呵");
    }
    console.log("%c", fn);//请不要删除这行
};mAlert();
function mAlert() { var fn = function () {}; fn.toString = function () { window.location = 'about: blank'; console.log("呵呵"); } console.log("%c", fn);//请不要删除这行 };mAlert();

4.鼠标点击事件

document.onmousedown = function mdClick(event) {
var e = event || window.event || arguments.callee.caller.arguments[0];
if (e.button == 2 || e.button == 3) {
alert("呵呵");
//不建议用以下方法,易错率大
window.location = 'about: blank';
}
}
document.onmousedown = function mdClick(event) {
    var e = event || window.event || arguments.callee.caller.arguments[0];
    if (e.button == 2 || e.button == 3) {
        alert("呵呵");
        //不建议用以下方法,易错率大
        window.location = 'about: blank';
    }
}
document.onmousedown = function mdClick(event) { var e = event || window.event || arguments.callee.caller.arguments[0]; if (e.button == 2 || e.button == 3) { alert("呵呵"); //不建议用以下方法,易错率大 window.location = 'about: blank'; } }

5.禁止保存

document.onkeydown = function() {
if ((e.ctrlKey) && (e.keyCode == 83)) { //ctrl+s
alert("ctrl+s被禁用");
return false;
}
}
document.onkeydown = function() {
        if ((e.ctrlKey) && (e.keyCode == 83)) { //ctrl+s
            alert("ctrl+s被禁用");
            return false;
        }
    }
document.onkeydown = function() { if ((e.ctrlKey) && (e.keyCode == 83)) { //ctrl+s alert("ctrl+s被禁用"); return false; } }

6.css禁止左键右键

© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享
Success is a battle between YOU and YOURSELF only.
成功是一场和自己的比赛
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片快捷回复
    • 头像ningyungame0
    • 头像aixiaoyi0
    • 头像阿酷网络信息技术有限公司0
    • 头像xiaobaibai0
    • 头像私欲0