如何在网页中禁止右键查看
相信大多数站长为了保护站点信息版权也是煞费苦心。那么有没有一个有效的保护版权的方法呢?当然有啦,这就是网站静止右键。那么如何禁止右键呢?方法如下:
禁止鼠标左右键
禁止鼠标左右键代码/禁止网页选中/禁止另存为/防复制代码
function stop(){
return false;
}
document.oncontextmenu=stop;
禁止选中代码
document.oncontextmenu=new Function("event.returnValue=false;");
document.onselectstart=new Function("event.returnValue=false;");
禁止另存为
防拷贝/复制代码
禁止选择文本
var omitformtags=["input", "textarea", "select"]
omitformtagsomitformtags=omitformtags.join("|")
function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}
function reEnable(){
return true
}
if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
禁止网页另存为
禁止选择文本
var omitformtags=["input", "textarea", "select"]
omitformtagsomitformtags=omitformtags.join("|")
function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}
function reEnable(){
return true
}
if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
禁用右键
function stop(){
return false;
}
document.oncontextmenu=stop;
真正的鼠标右键屏蔽
版权声明:本站【趣百科】文章素材来源于网络或者用户投稿,未经许可不得用于商用,如转载保留本文链接:https://www.qubaik.com/article/149441.html