karlmumbai
New Member
Code: \[code\](function($){ $.fn.ctrl = function(key, callback) { if(typeof key != 'object') key = [key]; callback = callback || function(){ return false; } return $(this).keydown(function(e) { var ret = true; $.each(key,function(i,k){ if(e.keyCode == k.toUpperCase().charCodeAt(0) && e.ctrlKey) { ret = callback(e); } }); return ret; });};$.fn.disableSelection = function() { $(window).ctrl(['a','s','c']); return this.each(function() { $(this).attr('unselectable', 'on') .css({'-moz-user-select':'none', '-o-user-select':'none', '-khtml-user-select':'none', '-webkit-user-select':'none', '-ms-user-select':'none', 'user-select':'none'}) .each(function() { $(this).attr('unselectable','on') .bind('selectstart',function(){ return false; }); }); });};})(jQuery);$(document).ready(function(){ $("textarea").on('focus',function(){ $(this).disableSelection(); });});\[/code\]Fiddle: http://jsfiddle.net/EBhya/8/The idea behind it is that the user can type, but cannot highlight text. Changes and such can still be made with arrow keys and what not. On Firefox and IE, this works 100% as desired. On Chrome, and probably on Safari, the input is disabled when you focus on it and you cannot even type.I have tried everything from waiting until \[code\]keydown\[/code\] to apply the disabled selection, to trying to monitor the mouse clicks and selection. Anyway, if anyone can help, I would greatly appreciate it.