2009
Apr
15
Disable Text Selection
With CSS
Example
- <div unselectable="on"></div> /* For IE */
Example
- .text-selection {
- user-select: none;
- -moz-user-select: none; /* For Firefox */
- -khtml-user-select: none; /* For Safari */
- -o-user-select: none; /* For Opera */
- }
With JavaScript
Example
- var disableTextSelection = function(element) {
- element.unselectable = "on"; /* For IE */
- element.style.UserSelect = "none";
- element.style.MozUserSelect = "none"; /* For Firefox */
- element.style.KhtmlUserSelect = "none"; /* For Safari */
- element.style.OUserSelect = "none"; /* For Opera */
- };
回應 (Leave a comment)