DelphiFAQ Home Search:

Disable text selection with the mouse


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


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


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.onmousedown =
    function (evt) { return false; };

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

Content-type: text/html


2006-10-06, 11:39:59
anonymous from Malaysia  
2007-01-13, 22:46:42
anonymous from United States  
2008-04-12, 08:45:30   (updated: 2008-04-12, 08:48:41)
anonymous from United States  
Check out the tool at 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, 23:52:30
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  
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
2009-01-08, 21:13:18
anonymous from United States  
Hello ! Jake thanks for the reply today is Jan 08, 2009 . I am just reading it today before I could not find it. Anyway I told him I wanted his E-mail password and he gave it to me so I went in to it and BOY did I get more then I wanted too ! I found many E-mails 's to other woman and well I don't think I need to say anymore now that I no longer send him funds or anything I don't here from him anymore So I guess I was right ALL THE LONG !!! This went on long enough almost 4 years . Well I guess I learned alot from this ~! Thank you again , I just don't understand why men do this (it is mostly men that scame) ? P.S I also sent a letter to his Pastor asking him for info about Light Roves A.K.A. Light Sevor because if he was going to come to the United States I want'ed to make sure what he was saying was real and I have two boys at home so I was not just going to bring him here without getting a letter from his pastor the last phone call from him was on 12/31/08 Take Care , Miss WRONG & SUCKERED
2009-02-27, 08:45:31
anonymous from China  
very good. i need it
2009-08-22, 05:07:42
anonymous from Poland  
document.onmousedown = null;
document.onselectstart = null;
2009-12-10, 03:59:36
anonymous from United Arab Emirates  
2010-05-27, 13:53:32  
but i have a problem:
I need a script that let users select a text but with a certain length (for example 100 characters) and disable it when the text is selected more than a number,
my java script is low,please help me with this problem ! :(
2012-08-04, 17:18:09   (updated: 2012-08-04, 17:20:07)
anonymous from Switzerland  

on 'zoosk' in switzerland

2017-11-27, 19:52:38
anonymous from Indonesia  



NEW: Optional: Register   Login
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, or post under a registered account.

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:

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.

photo Add a picture: