爱德华网络世界

当前位置:首页 > 精品文萃 > 电脑互联 > 内容

禁止右键菜单代码、禁止复制粘贴代码

作者:不详    更新时间:2020-8-16 5:09:29

代码如下:

<script type="text/javascript">
//屏蔽右键菜单
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;
}
}
</script>
原文:http://blog.cccyun.cn/post-224.html

来源:网络

特别声明:以上作品内容(包括在内的视频、图片或音频)为用户上传并发布,本平台仅提供信息存储空间服务。如遇版权问题,请立即联系删除。

Notice: The content above (including the videos, pictures and audios if any) is uploaded and posted by the user. This platform merely provides information storage space services. In case of copyright issues, please contact us at the first time and we will remove the related content immediately.

  • 上一篇:如何优化你的网站
  • 下一篇:PPC,EPC,ROI,CPS,CPM,CPC,CTR等广告联盟术语名词解释
  • 相关评论

    我要评论

    大名: (*缺省将显示IP)
    内容:

    最新更新

    热门推荐

    手机端首页 | PC端

    © by Edward Web World