Connecting Tech Pros Worldwide Forums | Help | Site Map

How to disable text selection?

kj
Guest
 
Posts: n/a
#1: Jul 20 '05



Is there any way to disable text selection in a web page (or at
least render it invisible to the user)?

If there is a way to control how selected text and its background
are rendered, then the desired effect could be achieved by setting
these parameters to match those of regular text. In this way, even
if text was selected, the user would not see that it was.

Thanks!

kj

Martin Honnen
Guest
 
Posts: n/a
#2: Jul 20 '05

re: How to disable text selection?




kj wrote:[color=blue]
> Is there any way to disable text selection in a web page (or at
> least render it invisible to the user)?[/color]

There are browser dependant ways, example using CSS extensions for
Mozilla/Netscape and using script for IE5+:

<p>Normal paragraph.</p>
<p onselectstart="return false;"
style="-moz-user-select: none;">
Paragraph where selection is disabled.
</p>

Of course browser users can disable script or have user stylesheets
overriding your CSS settings.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Fabian
Guest
 
Posts: n/a
#3: Jul 20 '05

re: How to disable text selection?


kj hu kiteb:
[color=blue]
> Is there any way to disable text selection in a web page (or at
> least render it invisible to the user)?
>
> If there is a way to control how selected text and its background
> are rendered, then the desired effect could be achieved by setting
> these parameters to match those of regular text. In this way, even
> if text was selected, the user would not see that it was.[/color]

Please think carefully before you do this. All too often, web authors
use colour/background schemes that are hard to read, and sometimes
choose colour schemes that are impossible for colour blind people. For
these people, the fact that the colours do change is a valuable user
interface tool.


--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

DU
Guest
 
Posts: n/a
#4: Jul 20 '05

re: How to disable text selection?


kj wrote:
[color=blue]
> Is there any way to disable text selection in a web page (or at
> least render it invisible to the user)?
>
> If there is a way to control how selected text and its background
> are rendered, then the desired effect could be achieved by setting
> these parameters to match those of regular text. In this way, even
> if text was selected, the user would not see that it was.
>
> Thanks!
>
> kj[/color]

What you're asking is definitively not recommendable. It's clearly goes
against standard basic browser functionality. Whatever you do with
javascript or CSS can be overriden by the user.

FWIW, in Windows XP, only the user can set the background color (and
text color) of selected text:

Start/Settings/Control Panel/Display/Appearance tab/Advanced
button/Item:/Selected Items and here
Item: ... color 1
Font: ... color

DU
Closed Thread


Similar JavaScript / Ajax / DHTML bytes