March 28, 2015

How to restrict users to make a selection in the website

It's very simple to restrict the users to make a selection in the web page. Generally if you have some text rendering website in which you don't want to allow your users to select and copy the text from your web page then you use this simple code in your website.

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

user-select is a CSS property used to restrict the user selection in the website. You can also restrict the users to select the particular parts of your web page also just by putting that same code lines in that part of styling. Again those different suffixes are for cross browser compatibility issues. -webkit- is for chrome, safari etc and -moz- for Mozilla  and -ms- for internet explorer and -o- is for Opera and simple one is for other remaining browsers.

If any query please comment below. I am very happy to answer your queries.

No comments: