Could you tell us
why you want to do this? If you are trying to prevent visitors from copying your content, that's not possible. You may be able to prevent them from selecting it under normal circumstances, but that is extremely easy to work around.
However, the most reliable way I can think of is to cover whatever text you want disabled with another, empty and transparent element. That way when visitors try to select the text, they will be clicking the transparent element rather then the text below. - I say this is most reliable because it dose not require JavaScript. Can be done using HTML and CSS alone.
Your
onmousedown = "return false;"
method can also be applied more specifically to text elements alone. That is, you could do something like this:
-
var paragraph = document.getElementById('myParagraph');
-
paragraph.onmousedown = function() { return false; }
-
This would disable mouse interaction on the element with the ID 'myParagraph' and nothing else.
You can of course use things like the
document.getElementsByTagName
function to target more than a single element at a time. Just make sure the elements you target do not contain elements that visitors should be able to interact with.
Note, though, that this a JavaScript solution and can VERY easily be bypassed.