控制HTML页面内容不能选中的方法

方法有二

一: css 方法

user-seletct: none;
-webkit-user-seletct: none;
-moz-user-seletct: none;
-ms-user-seletct: none;

none: 不能选中内容

text: 能选中内容

二:js 方法

document.body.onselectstart = function(){
  return false;
}

返回 false,不能选中

返回 true,能选中

 

posted @ 2018-03-05 15:59  s_qiu  阅读(7938)  评论(0编辑  收藏  举报