网页防扒技术合集

1.禁用浏览器右键菜单

document.oncontextmenu = new Function("return false;");

2.监听键盘事件

<div class="enlighter-default enlighter-v-standard enlighter-t-enlighter enlighter-hover enlighter-linenumbers enlighter-overflow-scroll">
<div class="enlighter">
<div class="">
<div>
<pre><code class="gl">function mAlert() {
var fn = function () {};
fn.toString = function () {
window.location = 'about: blank';
console.log("呵呵");
}
console.log("%c", fn);//请不要删除这行
};mAlert();</code></pre>
</div>
</div>
</div>
</div>

3.检测控制台

<div class="enlighter-default enlighter-v-standard enlighter-t-enlighter enlighter-hover enlighter-linenumbers enlighter-overflow-scroll">
<div class="enlighter">
<div class="">
<div>
<pre><code class="gl">function mAlert() {
var fn = function () {};
fn.toString = function () {
window.location = 'about: blank';
console.log("呵呵");
}
console.log("%c", fn);//请不要删除这行
};mAlert();</code></pre>
</div>
</div>
</div>
</div>

4.鼠标点击事件

<div class="enlighter-default enlighter-v-standard enlighter-t-enlighter enlighter-hover enlighter-linenumbers enlighter-overflow-scroll">
<div class="enlighter">
<div class="">
<div>
<pre><code class="gl">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';
}
}</code></pre>
</div>
</div>
</div>
</div>

5.禁止保存

<div class="enlighter-default enlighter-v-standard enlighter-t-enlighter enlighter-hover enlighter-linenumbers enlighter-overflow-scroll">
<div class="enlighter">
<div class="">
<div>
<pre><code class="gl">document.onkeydown = function() {
if ((e.ctrlKey) && (e.keyCode == 83)) { //ctrl+s
alert("ctrl+s被禁用");
return false;
}
}</code></pre>
</div>
</div>
</div>
</div>

6.css禁止左键右键

<div class="enlighter-default enlighter-v-standard enlighter-t-enlighter enlighter-hover enlighter-linenumbers enlighter-overflow-scroll">
<div class="enlighter">
<div class="">
<div>
<pre><code class="gl">//左键
〈body onselectstart="return false"〉


//右键
〈body οncοntextmenu='return false'〉</code></pre>
</div>
</div>
</div>
</div>
© 版权声明
THE END
点赞0
分享
评论 抢沙发
Limons的头像-隐匿者

昵称

取消
昵称表情代码图片