文本不让选中的实现

时间:2021-09-07 02:04:22   收藏:0   阅读:19

css:  

div {
    -moz-user-select:none;
    -webkit-user-select:none;
    user-select:none;
}

js:

// 先取到标签对象
if(document.all){ //for ie obj.onselectstart= function(){return false;}; }else{ obj.onmousedown= function(){return false;}; obj.onmouseup= function(){return true;}; } document.onselectstart = new Function(‘event.returnValue=false;‘);

  功能需要的话,最好双管齐下

原文:https://www.cnblogs.com/skytoangel/p/15232516.html

评论(0)
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!