Core tip:-moz-user-select and onselectstart ways to prevent text from being selected
On the internet to find a lot, but I tested a lot, found not perfect, or browser in mischief, a way that seems to only meet a browser
Onselectstart= "return false;" to meet the effect of IE, when only for a certain area, the statement of the paragraph in a certain area.
For example: <div onselectstart= "return false;" >********</div>; if you need to set the entire document is not selectable, directly in the body set onselectstart= " return false; Or it is used in javascript: Document.onselectstart=function () {return false;}
Style= "-moz-user-select:none", can satisfy Firefox under the effect, because onselectstart= "return false;" Can not produce the desired effect in Firefox, so can only be implemented in the way of CSS. Of course, as before, when you need the entire document to achieve this effect, the body's style directly set to:-moz-user-select:none;
Finally I have to say that Google's Chrome browser, when used in the input of these two ways, can not achieve the mouse can not choose the effect, I have not found a good way to solve
This is the test code that is compatible with most browsers:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title> test </title> </pead> <body> you can't pick me. </body> </ptml>