Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable selection of text on a web page

I am trying to make webpage very native. How to remove select,select all property in webpage?

like image 472
selva_pollachi Avatar asked Sep 07 '12 09:09

selva_pollachi


People also ask

How do I disable text selection copy cut/paste and right click on a Web page?

You can use jquery for this: $('body'). bind('copy paste',function(e) { e. preventDefault(); return false; });


1 Answers

Disable selection of every element with CSS

body {   -webkit-user-select: none;      -moz-user-select: -moz-none;       -ms-user-select: none;           user-select: none; } 

This is supported by Chrome, Safari, Firefox, IE 10, and iOS Devices. More info on MDN page.

Edit: If you want <input> and <textarea> to remain selectable in Firefox, add:

input, textarea {      -moz-user-select: text; } 

Disable context menu with jQuery

$(document).on("contextmenu", function (event) { event.preventDefault(); }); 
like image 78
Pavlo Avatar answered Sep 21 '22 20:09

Pavlo