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

mac2022-06-30  34

方法有二

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

 

转载于:https://www.cnblogs.com/s-qiu/p/8509458.html

最新回复(0)