Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Disable selecting text in HTML with javascript events (See related posts)

When you need to diable selection of text in a page use the following events in the wrapping tag. This is useful if you use javascript ondblclick and don't want the text to be selected.

onmousedown will stop the selection in Firefox. IE will still select text though so you must also use onselectstart to keep IE from selecting the text.

<td onmousedown="return false;" onselectstart="return false;">

You need to create an account or log in to post comments to this site.


Related Posts