質問

I am trying to disable text selection, and it works fine in all browsers but IE. I have added a bit of code to the css as well as to the index. It still is not disabling.

I have added this to the index:

$('#poet').disableSelection(); // deprecated in jQuery UI 1.9

$(el).attr('unselectable','on')
.css({'-moz-user-select':'-moz-none',
       '-moz-user-select':'none',
       '-o-user-select':'none',
       '-khtml-user-select':'none', /* you could also put this in a class */
       '-webkit-user-select':'none',/* and add the CSS class here instead */
       '-ms-user-select':'none',
       'user-select':'none'
 }).bind('selectstart', function(){ return false; });

 $("#123").bind( "selectstart", function(e){
    e.preventDefault();
    return false;
});

 $("#123").bind("selectstart", function (evt) {
    evt.preventDefault();
});

And this to the .css file:

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

Any help would be greatly appreciated. Thank you.

役に立ちましたか?

解決

Add both of these to your existing CSS class

-webkit-touch-callout: none;
user-select: none;

Additionally, you can check this link for more details.

http://msdn.microsoft.com/en-us/library/ie/jj152140(v=vs.85).aspx


Prevent text selection when dragging from outside target in IE7/8


Given that this post specifies "jquery" :

$("#inputID").focus(function() {
    $(this).blur();
}):
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top