Entry
How can I disable text selection (by mouse clicking/dragging)?
How can I disable text selection (by mouse clicking/dragging)?
Nov 5th, 2003 08:47
Klaus Bolwin, Martin Honnen,
With IE4+ the following works:
if (document.all)
document.onselectstart =
function () { return false; };
With NN4 the following works
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown =
function (evt) {
return false;
};
}
but note that it cancels every mousedown action which will prevent
other user action (link click, right click etc) as well.
For NN6
document.onmousedown =
function () { return false; };
disables text selection.
________________
For Mozilla & Co. you can use CSS to disable text selection:
selector {-moz-user-select:none;}