破解网站禁止复制页面内容和图片(老司机来教你一个绝招:网页禁止复制粘贴+禁止F12)
优采云 发布时间: 2022-01-31 13:07破解网站禁止复制页面内容和图片(老司机来教你一个绝招:网页禁止复制粘贴+禁止F12)
内容
相信很多SEO优化人员都有这样的经历:原创文章硬写,别人不打招呼,复制粘贴连1分钟都不到文章竟然更气人的是文章的文章排名竟然比我的原创还要高。因此,SEOer想了很多办法来防止页面被别人复制粘贴,但效果并不好。老司机教你一招:网页禁止复制粘贴+禁止右键+禁止F12。
网页禁止复制粘贴、右键、F12(老司机教你一招)
一. 网页禁止复制粘贴、右键、F12操作步骤禁止
步骤 1. 下载 JS 代码
JS代码
或者复制下面的JS代码,命名为nocopy.js
document.onkeydown = function(){
if(window.event && window.event.keyCode == 123) {
alert("不要扒网站啦,一首凉凉送给你");
event.keyCode=0;
event.returnValue=false;
}
if(window.event && window.event.keyCode == 13) {
window.event.keyCode = 505;
}
if(window.event && window.event.keyCode == 8) {
alert(str+"\n请使用Del键进行字符的删除操作!");
window.event.returnValue=false;
}
}
document.oncontextmenu = function (event){
if(window.event){
event = window.event;
}try{
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
return false;
}
return true;
}catch (e){
return false;
}
}
document.onpaste = function (event){
if(window.event){
event = window.event;
}try{
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
return false;
}
return true;
}catch (e){
return false;
}
}
document.oncopy = function (event){
if(window.event){
event = window.event;
}try{
var the = event.srcElement;
if(!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
return false;
}
return true;
}catch (e){
return false;
}
}
document.oncut = function (event){
if(window.event){
event = window.event;
}try{
var the = event.srcElement;
if(!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
return false;
}
return true;
}catch (e){
return false;
}
}
document.onselectstart = function (event){
if(window.event){
event = window.event;
}try{
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
return false;
}
return true;
} catch (e) {
return false;
}
}
步骤 2. 将 nocopy.js 放到 网站 的根目录下
步骤 3. 调用这个 JS 文件
在整个网站的head标签中,添加如下代码:
如何搭建一个WordPress站点,只需将上面这行代码添加到主题下header.php中的head标签即可。
二. 适用网页在什么情况下禁止复制粘贴、右键、F12
为了防止复制粘贴,很多SEO优化人员也选择“一刀切”,禁止复制粘贴整个网站、右键、F12。这种方法可取吗?
如果我们的网站内容是帮助用户解决问题,而用户只需要复制网站上的内容来解决他的问题,那么禁止复制粘贴的体验就很糟糕,而且很有可能导致大量用户流量丢失,甚至用户永远不想访问网站。
如果我们的网站内容主要供用户浏览或阅读,不涉及任何技术或代码,发布的内容为原创,我们不希望竞争对手使用。此时,禁止复制和粘贴。禁止右键,禁止F12完全OK。
如果我们的部分网站内容是为了展示公司的产品;另一部分是介绍产品的相关文章,用户只需要浏览了解即可,此时只需在相关的文章中添加禁止复制粘贴等代码。
因此,不同的情况需要我们灵活应对。当然,不可否认,网页禁止复制粘贴、禁止右键、禁止F12是为了保护网站的内容。但无论如何,用户体验的部分不容忽视!只有站在用户的角度思考,网站才能获得源源不断的流量。