Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I prevent the selection of text in IE?

I have the following CSS:

    * {
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -o-user-select: none;
        user-select: none;
    }

This works in every browser except for in IE, why is this? The selection of text looks really ugly because my menus are created from text and CSS... any ideas?

like image 621
Freesnöw Avatar asked May 23 '11 17:05

Freesnöw


1 Answers

You can use Javascript and do:

document.onselectstart = function() { return false; }
document.onmousedown = function() { return false; }

The first one works for IE and the second one does Mozilla-based browsers.

like image 79
Justin Avatar answered Oct 21 '22 23:10

Justin