码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2018-03-05 17:01:00      阅读:327      评论:0      收藏:0      [点我收藏+]

标签:tar   doc   nbsp   star   use   body   控制   on()   return   

方法有二

一: 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,能选中

 

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

标签:tar   doc   nbsp   star   use   body   控制   on()   return   

原文地址:https://www.cnblogs.com/s-qiu/p/8509458.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!