-1

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?

Community
  • 1
  • 1
QuinnBaetz
  • 559
  • 9
  • 23
  • As @TheifMaster has said, we know how much you accept answers, and the more you do, the more likely it is that the *smart guys* will give you an answer. (`smart != nice`) You can do this by clicking on the **check mark** below the *down vote* button. – Mateen Ulhaq Feb 16 '11 at 22:50
  • 1
    Please note: Anybody determined enough will find a way to copy stuff off of your page. – drudge Feb 16 '11 at 22:54

3 Answers3

4

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;"

Community
  • 1
  • 1
Martamius
  • 138
  • 3
1

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';
ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
0

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?

Community
  • 1
  • 1
Tim Down
  • 318,141
  • 75
  • 454
  • 536