防止屏幕移动 html5

Prevent screen from moving html5

当我使用 phone 的浏览器拖入网络应用程序的 canvas 时,整个屏幕都会移动。我该如何阻止它?

我输入的代码

<meta  charset="UTF-8" name="viewport"
 content="user-scalable=no,
          initial-scale=1.0,
          width=device-width,
          height=device-height,
          target-densitydpi=device-dpi"/>

您输入的是两个不同的元标记。改成

<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

还绑定select、触摸和拖动事件

element.onselectstart = function() { return false; };

element.ondragstart = function() { return false; };

element.ontouchstart = function(e) { e.preventDefault(); };

看看有帮助。