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;

  }

}

猜你喜欢

  • sql替换语句,用该命令可以整批替换某字段的内容,也可以批量在原字段内容上加上或去掉字符。 命令总解:update 表的名称 set 此表要替换的字段名=REPLACE(此表要替换的字段名, '原来内容', '新内容')

    数据库2021-05-19
  • 新建一个目录名为sitemap的栏目,然后从 /template/tools/ 中复制一个名为 sitemap.baidu.htm 的ICMS自带网站地图XML模板,到自己的模板文件夹中,然后去ICMS系统后台,为前面新建的sitemap栏目,列表模板调用该 sitemap.baidu.htm 模板文件。

    ICMS2021-06-03
  • <video>的基本属性: preload: (预加载)iPhone支持,Android不一定支持; poster: (封面图片)iPhone支持,Android不一定支持; autoplay: (自动播放)iPhone中的Safari不支持,webview可能被开启。Android不一定支持;

    html相关标签2021-09-01
  • <form method="post" name="form1" action="" enctype="multipart/form-data"> <a onclick="form1.submit()"><img src=""></a>

    html相关标签2021-09-15
  • location / { index  index.html index.htm index.php; try_files $uri $uri/ /rewrite.php?$args; }

    ICMS2021-10-09