FFan丶Blog / 部分JS效果 / / JS屏蔽右键、复制、粘贴、剪切

JS屏蔽右键、复制、粘贴、剪切

分类:部分JS效果 发布时间:2021-10-20 09:00:32来源:FFan丶Blog
//屏蔽右键菜单 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")) {...

//屏蔽右键菜单

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;

  }

}

猜你喜欢

  • 快速把excel合并在一起,方便分析和统计可以利用excel表的宏计算就可以实现。方法如下: 1、我们需要把多个excel表都放在同一个文件夹里面,并在这个文件夹里面新建一个excel。

    其他2020-01-15
  • Copyright &#169; <script>var d=new Date();document.write(d.getFullYear());</script> FFan. All rights reserved.

    部分JS效果2020-01-15
  • 四边为虚线边框:border:1px dashed #000; 左边为虚线:border-left:1px dashed #000; 右边为虚线:border-right:1px dashed #000; 顶部边(上边)为虚线:border-top:1px dashed #000; 底部边(下边)为虚线:border-bottom:1px dashed #000;

    CSS2020-01-15
  • 1、四个边框 border-left 设置左边框,一般单独设置左边框样式使用border-right 设置右边框,一般单独设置右边框样式使用border-top 设置上边框,一般单独设置上边框样式使用border-bottom 设置下边框,一般单独设置下边框样式使用,有时可将下边框样式作为css下划线效果应用。

    CSS2020-01-15
  • /*用CSS控制将li标签竖排变横排*/ display: inline-block; /*内边距*/ padding /*外边距*/ margin

    CSS2020-01-15