html防止文本被选中

如何防止浏览器中文本被选中呢?

IE中,使文本所在控件的onselectstart 事件返回false

 <script  type="text/javascript" charset="utf-8">
	window.onload=function()
	{
		var moveSpan222=$('#moveSpan');
		//alert(moveSpan222);
		drag(moveSpan222);
		if(isIEtest){//当浏览器是IE时
			com.whuang.hsj.$$id('moveSpan').onselectstart=function()//禁止文本被选中
			{
				return false;
			}
		}
	}
  </script>

 

火狐和chrome中,使用css

.cannot_select{
	-moz-user-select:none;/*火狐*/
	-webkit-user-select:none;/*webkit浏览器*/
	-ms-user-select:none;/*IE10*/
	-khtml-user-select:none;/*早期浏览器*/
	user-select:none;
}

 参考:http://www.baidu.com/link?url=TWlih_4XiCKFqWH7G4YRn_BscjzgEh8gQY2349euHmf2lWvc3USO3_FnP6LVMpbO3L-r5wH8T8_pz3PJpeHd6q

 

你可能感兴趣的:(禁止选中文本,防止选择,禁止选中,禁止选择,防止选中)