Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

make html text non selectable

Posted on 2008-10-03
7
865 Views
Last Modified: 2013-11-19
Hi there,
Is there a way to make part of the text on my html page non selectable?
0
Comment
Question by:ioustinos_sarris
  • 3
  • 3
7 Comments
 
LVL 35

Expert Comment

by:torimar
ID: 22635658
The only way that I could think of is to create an image with the text in question and then insert the image into your page instead of html text.

0
 
LVL 35

Expert Comment

by:torimar
ID: 22635828
A long while ago, javasripts were quite fashionable that disabled the right mouse button on a web page (like this one, for instance: http://www.dynamicdrive.com/dynamicindex9/noright.htm).

Theoretically, one could modify the script to prevent the left mouse button from being clicked. BUT:
- users might still select text with the cursor keys
- javascript can easily be turned off
- I don't think those scripts still work with new generation browsers


So, I'm left with my above mentioned suggestion.
Alternatively, you could try to place a transparent image in a <div> layer (http://www.echoecho.com/csslayers.htm) right on top of the text. So when the visitor wishes to select the text underneath, all he gets is the image. But I'd expect this to require a lot of fiddling.
0
 
LVL 20

Accepted Solution

by:
Gawai earned 500 total points
ID: 22636293
There is a way to overcome

if u disable right click, u can select the text, below site will help u out
ref
http://www.dynamicdrive.com/dynamicindex9/noselect.htm

or just try this

<body onselectstart = return false; >

0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 23

Expert Comment

by:Tony McCreath
ID: 22643025
Placing a div over the top of the text would stop selection.
0
 
LVL 20

Expert Comment

by:Gawai
ID: 22643629
the link i gave u does extacly wat u wanted
0
 
LVL 35

Expert Comment

by:torimar
ID: 22644441
gawai,

the link you gave indeed does what the OP wants, but the method itself suffers from the same disadvantage I mentioned above: it is Javascript dependent, and Javascript may be disabled in no time.

For instance: the link you gave also offers a demonstration of how the script works. I went there with my standard Opera browser, realized I couldn't select text, pressed F12, turned off Javascript, reloaded the page and selected the text. This took me about 4 seconds.
I then pasted the link into my Firefox browser which runs the No-Script extension by default, and I could select the text rightaway.

Hence: protecting your content with Javascript is like no protection at all.
0
 
LVL 20

Expert Comment

by:Gawai
ID: 22644472
then the best method is to use flash
load the text dynamically in flash MC.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question