板邓:js禁止复制网站页面代码

在需要禁止的页面引入一下代码即可:

var omitformtags=["input", "textarea", "select"]
  omitformtags=omitformtags.join("|")

  function disableselect(e){
  if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
  return false
  }

  function reEnable(){
  return true
  }

  if (typeof document.onselectstart!="undefined")
  document.onselectstart=new Function ("return false")
  else{
  document.onmousedown=disableselect
  document.onmouseup=reEnable
  }

  

posted @ 2016-07-24 11:02  贵隆  阅读(183)  评论(0编辑  收藏  举报