Android / iOS mobile browser - disable events

How to disable standard mobile browser events such as scaling (dblclick, expand) and options (when you hold your finger on the screen, a pop-up window appears with options)?

I tried this:

document.addEventListener('ontouchstart', function(event) 
{
event.preventDefault();
}, false);
+3
source share
2 answers

You can prevent your finger from moving (page scrolling) as follows:

document.addEventListener('ontouchstart', function(e) {
    e.preventDefault();
});

document.body.addEventListener('touchmove', function(e) {
    e.preventDefault();
});

And you just need to adjust the zoom viewportas follows:

<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
+2
source

If you set user-scaleable = no, the minimum and maximum values ​​are ignored. Therefore, if you want to disable scaling, you should use this:

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
0
source

All Articles