追求卓越,资源共享

-moz-user-select与onselectstart 禁止选择文字的方法

 

-moz-user-select与onselectstart 禁止选择文字的方法 鼠标禁用

上网一找,还不少,但是我测试了很多, 发现并不完美,还是浏览器在作怪,一种方式似乎只能满足一种浏览器
onselectstart="return false;",能够满足IE下的效果,当只针对某一个区域的时候,就把该段语句放在某一个区域中。

 

比如:<div onselectstart="return false;" >********</div>;假如 需要把整个文档都设定不能选择,就直接在body中设定onselectstart="return false;"或者是在Javascript中使用:document.onselectstart=function(){return false;}


style="-moz-user-select:none;",能够满足firefox下的效果,由于onselectstart="return false;"不能在firefox中产生希望的效果,所 以只能用css的方式来实现。当然和前面一样,当需要整个文档都达到这样的效果时,直接把body的样式设置为:-moz-user-select:none;。


最后我不得不说一下google的chrome浏览器,当在input中使用这 两种方式的时候,都不能达到鼠标不能选择的效果,我至今没找到好的办法来解决


这个 是兼容大部分浏览器的测试代码:

<html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>测试</title> 
</head> 
<body> 
<div onselectstart="return false;" style="-moz-user-select:none;" >你选不了我</div> 
</body> 

</html> 

{keywords:-moz-user-select与onselectstart 禁止选择文字的方法}是本站 (追求卓越,资源共享) 中一篇关于keywords:-moz-user-select与onselectstart 禁止选择文字的方法最经典的文章,欢迎您阅读和评论,您可以从百度搜索-moz-user-select与onselectstart 禁止选择文字的方法其它信息,也可以从google中查询更多-moz-user-select与onselectstart 禁止选择文字的方法的相关信息。
标签:-moz-user-select与onselectstart 禁止选择文字的方法
分类:技术交流| 发布:laibu| 查看: | 发表时间:2011-12-28
原创文章如转载,请注明:转载自黑暗天堂 http://www.918x.cn/
本文链接:http://www.918x.cn/post/moz-user-selectYuonselectstart-JinZhiXuanZeWenZiDeFangFa.html

相关文章

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

1 #北海情书
北海情书 哈哈!看看房哥~留个外链闪人~~
http://www.php0.net 2012-1-27 5:20:31 【REPLY】