Deselecting DIVs (or textboxes) content after being selected by user

I would like to prepare a javascript-based system that would deselect the text after the user selects it. The reason for this is to protect some articles on my site from being stolen by just pressing ctrl+c pair. I know it's always possible to omit it, but it's at least a little harder. What is more, I can't use jQuery while writing this script. What do you suggest?

Answers


My advice would be not to bother. JavaScript can easily be disabled or manipulated using a script console, source can be viewed and copied, etc. If anyone is going to steal those articles you won't be able to stop them without taking proper legal routes. What's more, you're inconveniencing the folks who have a genuine need to copy and paste something, like a quote or a search term.

That being said, IE, Chrome and Safari all support the onselectstart event, which is cancellable:

element.onselectstart = function () { return false; }

Firefox supports its own CSS style, -moz-user-select, which give the appearance that the text isn't selected, but doesn't disable it completely:

#element {
    -moz-user-select: none;
}

For Firefox, Opera and other browsers, however, there's no solution other than cancelling mousedown, double click and key events. There would be no way of capturing and blocking "select all" from the browser's menu.


Need Your Help

Materialized View Refresh with changing synonym pointer in SQL

oracle materialized-views synonym

I have two tables, TABLE_1 and TABLE_2. Then we have a synonym called TABLE that points to either TABLE_1 or TABLE_2. When TABLE_1 is active, an ETL populates TABLE_2 and when the run is complete...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.