I am making a webAPP, and using safari (on an iPAD) it happens that using the touchpad on BODY, where there are no other elements, the browser "reacts", it seems to "select" all the elements or something similar. In addition, by holding down the touchpad, the contextual menu appears (In Android it does not appear but the phone reacts by vibrating.
I would like to avoid these two things, without using libraries or frameworks.
Here is a video where I show my problem: Link
And here is a code example (the one seen in the video), with the solutions I've tried, capturing events and with CSS properties, but it doesn't seem to work.
document.ontouchmove = function(event){event.preventDefault();}
document.onmousedown = function(event){event.preventDefault();}
document.onclick = function(event){event.preventDefault();}
document.ondblclick = function(event){event.preventDefault();}
document.oncontextmenu = function(event){event.preventDefault();}
document.ondrag = function(event){event.preventDefault();}
function colorRandom(){
var color=["red","green","blue","yellow","orange","cyan"];
IDpantalla.style.backgroundColor=color[Math.floor(Math.random()*color.length)];
}
IDpantalla.ontouchmove=function(){colorRandom();};
IDpantalla.onclick=function(){colorRandom();};
BODY {
background-color:silver;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-webkit-tap-highlight-color: transparent;
-webkit-user-drag: none;
}
#IDpantalla {
position:fixed;
width:300px;
height:300px;
background-color:salmon;
}
<HEAD>
<META name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=0">
<META name="apple-mobile-web-app-capable" content="yes">
<META name="mobile-web-app-capable" content="yes">
<META name="apple-mobile-web-app-status-bar-style" content="black">
</HEAD>
<BODY>
<DIV id="IDpantalla"></DIV>
</BODY>
View Demo
The solution is to select
html
y in javascriptwindow
.CSS
JS
Side note: Do not use capital letters in tags