2

It has been discussed how to disable text from being selected: How to disable text selection highlighting using CSS?

However, I have yet to find a solution that blocks the user from selecting text when dragging from outside the intended target. I'm looking for a solution that works in IE 7/8.

Any ideas?

Community
  • 1
  • 1
Jonathan Baran
  • 291
  • 1
  • 4
  • 15
  • possible duplicate of [Making things unselectable in IE](http://stackoverflow.com/questions/4448671/making-things-unselectable-in-ie) – Esailija Jun 18 '12 at 20:00

1 Answers1

1

The IE8- onselectstart event and unselectable attribute solutions have already been discussed.

The CSS solution has been published as well. Here is the gist:

<!-- 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 */
}
Community
  • 1
  • 1
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265