By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,247 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,247 IT Pros & Developers. It's quick & easy.

How can I prevent user from selecting text??

P: n/a
I'm desinging a graphical interface and I frequently
take advantage of the double click event. Unfortunately in most browsers
double clicking also involves selecting and I would like to avoid that
since whatever is selected has dark blue background and white letters what
spoils the whole visual effect.... Any way I can block it por avoid it?
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Paweł wrote:
I'm desinging a graphical interface and I frequently
take advantage of the double click event. Unfortunately in most browsers
double clicking also involves selecting and I would like to avoid that
since whatever is selected has dark blue background and white letters what
spoils the whole visual effect.... Any way I can block it por avoid it?


No.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #2

P: n/a
Ivo
Paweł asked
I'm desinging a graphical interface and I frequently
take advantage of the double click event. Unfortunately in most browsers
double clicking also involves selecting and I would like to avoid that
since whatever is selected has dark blue background and white letters what
spoils the whole visual effect.... Any way I can block it por avoid it?


Not in all browsers:
<p unselectable="on">Try me!<p> <!-- if IE -->
<script>
document.onselectstart=new Function ("return false"); // if IE4+
if(window.sidebar){document.ondoubleclick=disables elect;} // if NS6
function disableselect(e){return false}
</script>
HTH
Ivo

Jul 23 '05 #3

P: n/a

"Paweł" <pm**@op.pl> wrote in message
news:16****************@www.okozaoko.pl...
I'm desinging a graphical interface and I frequently
take advantage of the double click event. Unfortunately in most browsers
double clicking also involves selecting and I would like to avoid that
since whatever is selected has dark blue background and white letters what
spoils the whole visual effect.... Any way I can block it por avoid it?


In the body tag, use the ondblclick event to focus an insignificant form
element:

<body ondblclick='document.forms[0].elements[1].focus()'>

I can't be selected with a double click.<BR><BR>

<form>
<textarea cols=30 rows=2 >Just try selecting me with a double
click...</textarea>
<input type=text size=1>
</form>

</body>

--
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.