CSS禁止文字选择

来源:互联网 发布:db2 查看数据库 名称 编辑:程序博客网 时间:2024/05/17 01:02
user-select有两个值:

none:用户不能选择文本

text:用户可以选择文本

需要注意的是:user-select并不是一个W3C的CSS标准属性,浏览器支持的不完整,需要对每种浏览器进行调整

body{   -moz-user-select: none; /*火狐*/   -webkit-user-select: none;  /*webkit浏览器*/   -ms-user-select: none;   /*IE10*/   -khtml-user-select: none; /*早期浏览器*/   user-select: none;}

IE6-9还没发现相关的CSS属性


//IE6-9document.body.onselectstart = document.body.ondrag = function(){    return false;}


0 0