Disable Text Selection

function doNothing(){ return false; }
function disableTextSelection(id) {
if (id=='all') var element=document;
  else var element=document.getElementById(id);
if (document.all)  // MSIE
   element.onselectstart = doNothing;
 else //Mozilla
   element.onmousedown = doNothing;
}
Use this script to disable the selection of text on a page. It's conducted by canceling the selection before it starts.
  • To disable text selection for entire document, assign 'all' as parameter, i.e.: disableTextSelection('all')
  • To attach the events to a specific element call the function with element id as parameter, i.e.: disableTextSelection('text1')
Text in this box is not selectable.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci suscipit lobortis ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan.