This concept was originally developed on Ajax Cookbook's Disable Text Selection by Bret Taylor, in 2006. I modified it slightly to use as a method for the Prototype library.
Object.extend(Element.Methods, { disableSelection: function(el) { with(el) { onselectstart = function() { return false; }; unselectable = 'on'; style.MozUserSelect = 'none'; style.cursor = 'default'; } } }); Element.addMethods();
You can easily call it like this:
Be sure you include the Element.addMethods(); part, or it won't work. Also, if you're not familiar with the with() statement (searching for "javascript with" on Google is pretty much worthless), read up about it over at the Mozilla Developer Center.