禁止拖动图片文字,禁止模态框底层可以滚动

图片拖动:

document.getElementsByTagName('img')[0].onmousedown = function(e){
    e.preventDefault()
};

在ie11及10会出现拖拽不了改成ondragstart事件
 
参考:https://stackoverflow.com/questions/4211909/disable-dragging-an-image-from-an-html-page

禁止拖动文字

document.onselectstart=function(){return false;};
 document.onselectstart=function(){return true;};
禁止鼠标右键保存图片
<img src=""  oncontextmenu="return false;">
禁止鼠标拖动图片
<img src="" ondragstart="return false;">
文字禁止鼠标选中
<p onselectstart="return false;">文字禁止鼠标选中</p>
禁止复制文本
<p onselect="document.selection.empty();">文字禁止鼠标选中</p>
jquery禁止文本复制和拷贝
$(document).bind("contextmenu copy selectstart", function() {
      return false;
});
jquery禁止图片拖拽
var img=$("img");
img.on("contextmenu",function(){return false;});
img.on("dragstart",function(){return false;});

禁止模态框底层可以滚动

参考:https://blog.csdn.net/qq_35430000/article/details/87076146

显示模态框时:document.body.style.overflow='hidden';
隐藏模态框时:document.body.style.overflow='';

移动端://滑动限制
stop() {
  var mo = function (e) {
    e.preventDefault();
  };
  document.body.style.overflow = 'hidden';
  document.addEventListener("touchmove", mo, false); //禁止页面滑动
}

//取消滑动限制
move() {
  var mo = function (e) {
    e.preventDefault();
  };
  document.body.style.overflow = ''; //出现滚动条
  document.removeEventListener("touchmove", mo, false);
}
原文地址:https://www.cnblogs.com/little-ab/p/11533603.html