如果我将这种样式用于 <body>
onmousedown='return false;' onselectstart='return false;'
是否可以通过对输入文本区域和选择使用 javascript 来给出异常(exception)? 如果是,那么你能告诉我怎么做吗?
最佳答案
实际上,您可以禁用文本选择而不需要笨重的 JavaScript 事件处理程序。在这里查看我的答案:How to disable text selection highlighting using CSS?
总结:在IE中使用CSS和unselectable
expando。
CSS:
*.unselectable {
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
user-select: none;
}
HTML:
<div id="foo" unselectable="on" class="unselectable">...</div>
关于javascript - 禁用文本选择并添加异常(exception),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4712030/