Preventing the browser from selecting text
Browser, Events May 6th, 2007There are many situations in which you don't want the browser to select the text (or selectable element, e.g. an image), when the user is moving the mouse holding the left mouse button. Especially during drag-and-drop actions this browser behavior will look strange and confuse the user.
To prevent this action on Internet Explorer, first add the proprietary event onselectstart to the particular element. Then assign a function which returns false.
On Gecko bases browsers you have to use the CSS attribute -moz-user-select. The prefix "-moz" shows, that this attribute (as many others, e.g. -moz-border-radius) is a proprietary one and will not work on other browers. The expression -moz-user-select:none; will prevent the browser from it's normal selecting behavior.


June 20th, 2008 at 13:23
[...] one year ago I published my first post in this blog. Until now I have been assiduously writing 43 posts in 16 categories, which results in [...]