New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css] 第40天 怎么才能让图文不可复制? #149
Comments
-webkit-user-select: none; |
postcss + user-select: none; 😆 |
user-select:none |
利用 |
// 禁止右键菜单
document.body.oncontextmenu = e => {
return false;
// e.preventDefault();
}
// 禁止文字选择
document.body.onselectstart = e => {
return false;
// e.preventDefault();
}
// 禁止复制
document.body.oncopy = e => {
return false;
// e.preventDefault();
}
// 禁止粘贴
document.body.onpaste = e => {
return false;
// e.preventDefault();
} CSS方式: /* CSS禁止文本选择,这样不会触发js */
body {
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
} 使用 示例中 |
-webkit-user-select: none; |
|
NODRAG? |
第40天 怎么才能让图文不可复制?
The text was updated successfully, but these errors were encountered: