I hava a list for name, it can click to show detail of each.But I don't want names of that list be select and copy.It just a protect.How to do?
can put a transparent layer on it, or use onselectstart event,but not good
I hava a list for name, it can click to show detail of each.But I don't want names of that list be select and copy.It just a protect.How to do?
can put a transparent layer on it, or use onselectstart event,but not good
With this CSS
.unselectable {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
And this HTML
<body>
<p class="unselectable">The user is not able to select this text in Firefox, Chrome, Safari and IE.</p>
</body>
The paragraph can't be selected.
It's nice for buttons and things where the text is not useful to copy and paste.
This can't be considered security, as the user can obviously disable the CSS or just view source. (Or use wget/curl/raw sockets to get the content).
Browser support is pretty good: http://caniuse.com/user-select-none
IE10 and up (though of course IE10 is now the most popular version of IE), + all other browsers.
If for some reason you are supporting older versions of IE with such a trivial feature, you can add unselectable="on"
on the element.
If it's just for esthetic because you need some action in Javascript which make weird thing with the selection, you can disabled the user selection by this CSS property:
.block {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
However, the user will always be able to select the content by an other manner: source code, by deactivate the CSS, save the page on his disk, etc. You can't protect your data from being copy on the Internet. If you want to keep it for you only, don't share it on the Web :) See also this post which explains the subject for another problem.
When you want to protect information, don't put it on the internet - simple as that.
That being said, one way to make text less machine-readable would be to turn it into an image. But it would still be possible to extract the text using optical character recognition. Obfuscating the text like in a captcha could make this harder, but 1. still not impossible (breaking captchas is a well-researched field) and 2. make the user-experience worse, especially for vision-impaired people.
Well you can disable right click on page using JavaScript but it won't prevent user from copying content from your website.
There are still other options to copy content:
If you put something on Internet, there are chances of getting it copied. You can prevent normal users from copying using JavaScript and other measurements but advanced user will copy it any way.
you can try to render all texts as images, no one can stop them using print screen but at least there will be no copying. see imagettftext (http://php.net/manual/en/function.imagettftext.php) or http://sgss.co/previous/experiments/phpfontimagegenerator2/
or just google some more methods of rendering text as image.
You can't. Don't try.
If the user can see it, they can copy it (somehow).