473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

How to disable text selection?

kj

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
Jul 20 '05 #1
3 7129


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


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/

Jul 20 '05 #2
kj hu kiteb:
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.


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

Jul 20 '05 #3
DU
kj wrote:
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


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
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: yair | last post by:
hey all i have a page with a table, and when the user doubleclicks a row in it, a window is opened. The problem is, if he doubleclicked a text in the row, it's becoming selected. what i want is...
30
by: Blnukem | last post by:
Hi All I'm new to javascript and was wondering if someone can help me with this I want to disable my second and third drop-box if the first one is selected to "Closed" I think I'm close but just...
20
by: kj | last post by:
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...
4
by: Grant Schenck | last post by:
I want to append text to the end of a text box. If the cursor is currently at the end I just want to append it and have the normal scrolling take place if needed. However, if the selection...
2
by: mask | last post by:
example: function disableText() { return false; } document.addEventListener("mousedown", disableText, false); i search many examples that use document.onmousedown = sidableText, so, how...
6
by: Brandon McCombs | last post by:
Hello, I have a form that contains a listview on the left side and a column of buttons on the right side. Only some of the buttons do I want enabled all the time. The other buttons should be...
2
by: sourabhmca | last post by:
Hi Friend. I have used a frame inside the html page where in I am displaying the content of other html page.. I want to disable text selection of the content inside the frame.. Can you please show...
3
by: Venturini | last post by:
I am trying to put together a web page where the customer makes choices of products and is then given a total. I am extremely new to Javascript and have managed to get as far as I have from web...
1
by: Jstyle | last post by:
I have a macro in MS Word that does several hundred find and replace statements. The problem is each time it does a find and replace it prompts me do you want to search from the begining. How do I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.