禁止图片拖拽和文字被选中

禁止图片拖拽

method1

img{pointer-events:none} ,firefox支持,IE不支持

method2

<body  ondragstart='return false'></body> || img{ondragstart='return false'}

method3

<body onselectstart='return false' onselectstart='no' style="-moz-user-select:none;">

method4

obj.onmousemove=function(ev){

  ev.preventDefault()

}

method5

obj.onmouseenter=function(ev){

  //设置捕获

  this.setCapture && this.setCapture()

}

obj.onmouseleave=function(ev){

  //清除捕获

  this.releaseCapture && this.releaseCapture()

}

禁止文字选中

 body{

  -webkit-touch-callout: none;

  -webkit-user-select: none;

  -khtml-user-select: none;

  -moz-user-select: none;

  -ms-user-select: none;

  user-select: none;

}

 

posted @ 2017-03-28 10:07  少华ShaoHua  阅读(284)  评论(0编辑  收藏  举报