css
body, div
{
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
,
input, textarea, .userselecton
{
-webkit-touch-callout: text;
-webkit-user-select: text;
-khtml-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
-o-user-select: text;
user-select: text;
}
-moz-none, , .
IE
<script type="text/javascript">
window.addEvent( "domready", function()
{
document.addEvent( "selectstart", function(e)
{
if ( (e.target.tagName == "INPUT") ||
(e.target.tagName == "TEXTAREA") ||
(e.target.hasClass("userselecton")))
{
return true;
}
return false;
} );
} );
</script>
This not only prevents the selection of background text, but also allows you to select input fields and the element in which you put the userseleton class.
source
share