DelphiFAQ Home Search:

Disable text selection with the mouse

 

comments8 comments. Current rating: 4 stars (3 votes). Leave comments and/ or rate it.

Question:

How can I disable text selection by mouse clicking or dragging of a text block?

Answer:

You could disable any mouse-down event with code as shown below (to be put in an onload event. The downside of this is that nothing will work anymore, not even clicks on links.

Also know that a user still can click on the document and use 'Select All' from the Edit menu (or in Internet Explorer even use a shortcut Control+A), followed by 'Copy' from the menu.

There is simply no way to protect displayed content, you can only make it a bit more difficult.

// Internet Explorer:
if (document.all)
  document.onselectstart =
    function () { return false; };

// Netscape 4:
if (document.layers) {
  document.captureEvents(Event.MOUSEDOWN);
  document.onmousedown =
    function (evt) { return false; };
}

// Netscape 6:
document.onmousedown = function () { return false; };


Comments:

2006-10-06, 11:39:59
anonymous from Malaysia  
thanks
2006-11-21, 14:56:26
anonymous from United States  
how do i turn it back on?
2007-01-13, 22:46:42
anonymous from United States  
rating
koszi
2007-05-09, 07:08:09
anonymous from Zimbabwe  
You spelled harare wrong. Harare is how you spell it :)
2008-04-12, 08:45:30   (updated: 2008-04-12, 08:48:41)
anonymous from United States  
Check out the tool at http://www.enc.rypt..select.php also. It is an alternative method to using Javascript to disable selecting text on a web page.

The tool there inserts invisible characters into text which make it near impossible to copy and paste text.

Javascript can easily be turned off on the browser, rendering any Javascript disabled.
2008-10-04, 16:59:07
anonymous from India  
rating


the comment is very bad

Keywords:

2008-10-04, 23:52:30
anonymous  
I added a photo of someone that I was trying to find out if he is a SCAMER or not . Do you post them for all to see ? Or only use it as a TEST PHOTO ? That is how I sent it I guess I am not sure how this site works, So if you would please let me know how to work it , I really need to know about this person as I may have been a SUCKER for to long! Light Roves is the name he is from Ghana Africa As I see many Woman from Ghana that have SCAMED many men and it is wrong as this may be the case for me with this man I am not sure any Truth would be of great help! Thanks 'Miss Don't want to be WRONG'
2008-10-05, 08:35:01   (updated: 2008-10-05, 08:35:56)
anonymous from United States  
rating
Listen sweetheart you should post the email letters and all the pics you have of this guy 90% sure this guy is a scam if you want help you can get it from this site. people will help here jake

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Los Angeles, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.