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;

  }

}

猜你喜欢

  • 文章列表 文章标题:<!--{$article_list.title}--> 文章链接:<!--{$article_list.url}--> 图片属性:pic="true" 随机排序:orderby="rand" 行号 (从1开始):<!--{$article_list.rownum}--> 

    ICMS2020-01-15
  • .pagelist a,.pagelist span {border-style: solid;border-width: 1px;border-color: #e91e63;margin: 5px;padding: 4px 10px;} .pagelist span.page_nowindex {background-color: #e91e63;}

    ICMS2020-01-15
  • 获取 10个分类下 每个分类最新的10篇文章<!--{iCMS:category:list loop="true" row="10"}--> <a href="<!--{$category_list.url}-->"><!--{$category_list.title}--></a>  <!--{iCMS:article:list loop="true" row="10" cid="$category_list.cid"}-->    <a href="<!--{$article_list.url}-->&quo

    ICMS2020-01-20
  • 一般的文字截断(适用于内联与块):.text-overflow {     display:block;/*内联对象需加*/     width:31em;/*指定宽度*/     word-break:keep-all;/* 不换行 */

    CSS2020-04-13
  •     <!-- 声明文档使用的字符编码 -->     <meta charset='utf-8'>     <!-- 优先使用 IE 最新版本和 Chrome -->     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>

    html相关标签2020-07-06