HTML text unselectable but with a twich ! UNDELETABLE
I know about -moz-user-select : none; -webkit-user-select : none; -khtml-user-select : none; and it works fine in the code i have .
But i want to make my div unselectable by Ctrl+A also , which the above directives don't seem to have an effect on.
How can i disable this selection in Firefox for example? I want to be able to prevent selection with Ctrl+A so that the Del key won't delete the text. I want to make the text un-deletable.
Thanks a lot!
您可以按如下方式禁用Ctrl-A按键,但这不会完成整个工作,因为浏览器的上下文和编辑菜单仍将具有“全选”选项。
document.onkeydown = function(e) {
e = e || window.event;
if (e.ctrlKey && e.keyCode == 65) {
return false;
}
};
Using this with the CSS above:
::selection {
background: rgba(0,0,0,0);
}
::-moz-selection {
background: rgba(0,0,0,0);
}
Won't necessarily make it unselectable, but the user won't be able to see what's being selected. ;)
Edit: In response to your comment below, take a look at this: http://jsfiddle.net/Shaz/fM8p4/
It's not entirely clear what you're trying to do; are you looking for something like this:
<div contenteditable="true">
This part is editable.
<div contenteditable="false">
This part is not editable or deletable.
</div>
This part is editable again.
<div>
链接地址: http://www.djcxy.com/p/41386.html
上一篇: 调整图像大小以适应div容器