已经讨论了如何禁用选定的文本:
How to disable text selection highlighting using CSS?
但是,我还没有找到一个解决方案,阻止用户在从预期目标外部拖动时选择文本。我正在寻找一个解决方案,在IE 7/8工作。
有什么想法吗?

最佳答案

已经讨论了IE8-onselectstart eventunselectable attribute解决方案。
CSS solution也已出版。要点如下:

<!-- save this file as unselectable.htc and remember where you put it -->
<public:component lightweight="true">
    <public:attach event="ondocumentready" onevent="unselectable()" />
    <script type="text/javascript">
        function unselectable(){
            element.onselectstart = function(){ return false; };
            element.setAttribute('unselectable', 'on', 0);
        }
    </script>
</public:component>

/* add this rule to the existing CSS file */
.unselectable {
    user-select: none;
    -moz-user-select: none;
    -khtml-user-select: none;
    behavior: url(unselectable.htc); /* change this path as needed */
}

09-07 19:06