Possible Duplicate:
What is the best way to prevent highlighting of text when clicking on its containing div in javascript?
When a user clicks and drags how do you stop firefox from highlighting your content?
Possible Duplicate:
What is the best way to prevent highlighting of text when clicking on its containing div in javascript?
When a user clicks and drags how do you stop firefox from highlighting your content?
This has already been answered here: What is the best way to prevent highlighting of text when clicking on its containing div in javascript?
Basically, for firefox, you should be able to do this in CSS:
div.noSelect {
-moz-user-select: none;//mozilla browsers
-khtml-user-select: none;//webkit browsers
}
For IE you can apparently "add a handler to the ondragstart event, and return false;"
If you are using jQuery UI on your page, you can simply use $('body').disableSelection();
If not, try this (this is what disableSelection()
does):
var elem = document.body;
elem.onselectstart = function() { return false; };
elem.MozUserSelect = 'none';
elem.unselectable = 'on';
You can do this with the unselectable
expando property in IE and CSS in other browsers. See this answer for more details: How to disable text selection highlighting using CSS?