拖动效果,防止选中文字兼容代码
方法一:如果只要一部分不选中文字可以在不要的那部分添加一个mark(遮罩)层。
方法二:css的方法 代码示例如下:
*{
-webkit-touch-callout:none; /*系统默认菜单被禁用*/
-webkit-user-select:none; /*webkit浏览器*/
-khtml-user-select:none; /*早期浏览器*/
-moz-user-select:none;/*火狐*/
-ms-user-select:none; /*IE10*/
user-select:none;
}
input{
-webkit-user-select:auto; /*webkit浏览器*/
}
textarea{
-webkit-user-select:auto; /*webkit浏览器*/
}
方法三: 代码示例如下:
document.onmousemove = (e) => {
let et = e || window.event;
et.preventDefault(); // 阻止默认事件发生
};
//虽然可以但是对别的页面有影响,所以不用这个
document.onmousemove = function () {
window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
}
凑字数凑字数凑字数凑字数凑字数凑字数凑字数凑字数凑字数凑字数凑字数凑字数凑字数