博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jq屏蔽鼠标右键复制,粘贴,选中功能
阅读量:6935 次
发布时间:2019-06-27

本文共 1649 字,大约阅读时间需要 5 分钟。

//屏蔽右键菜单

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;
  }
}

转载于:https://www.cnblogs.com/mechelle-olivia/p/8301290.html

你可能感兴趣的文章
nginx自定义模块编写-实时统计模块--转载
查看>>
【leetcode】 search Insert Position(middle)
查看>>
我爱免费之FreeFileSync文件夹同步软件
查看>>
lufylegend:图片的加载和显示
查看>>
献给所有从事IT行业拥有梦想的英语渣们
查看>>
Linux命令-更新系统时间和硬件时间
查看>>
音频AAC编码浅析
查看>>
linux系统时间和硬件时钟问题(date和hwclock)
查看>>
你用过这种奇葩的C#注释吗?如何看待
查看>>
memcache安装
查看>>
我的第一个DMZ方案实践
查看>>
HTML5--Video
查看>>
UVM中的regmodel建模(三)
查看>>
如何查看LoadRunner虚拟用户(vuser)类型
查看>>
oracle截取字符串区间段的一部分字符串
查看>>
Ubuntu Gnome 14.04.2 lts 折腾笔记
查看>>
前台的js对象数组传到后台处理。在前台把js对象数组转化为json字符串,在后台把json字符串解析为List<>...
查看>>
HTML目录
查看>>
【Hibernate学习笔记-5】@Formula注解的使用
查看>>
java ClassLoader static
查看>>