如何禁用在网页上的文本选择 [英] How to disable selection of text on a web page
本文介绍了如何禁用在网页上的文本选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想让网页非常原生。
如何清除选择,选择网页中的所有属性?
I am trying to make webpage very native. How to remove select,select all property in webpage?
推荐答案
>
Disable selection of every element with CSS
body {
-webkit-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
user-select: none;
}
Chrome,Safari,Firefox,IE 10和iOS设备。有关 MDN页面的详细信息。
This is supported by Chrome, Safari, Firefox, IE 10, and iOS Devices. More info on MDN page.
修改:如果您想要< input>
和< textarea>
要在Firefox中保持可选,请添加:
If you want <input>
and <textarea>
to remain selectable in Firefox, add:
input,
textarea {
-moz-user-select: text;
}
使用jQuery禁用上下文菜单
Disable context menu with jQuery
$(document).on("contextmenu", function (event) { event.preventDefault(); });
这篇关于如何禁用在网页上的文本选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文