How can I disable default mobile browser events like zoom (dblclick, expand) and options (when you hold down your finger on a screen a popup appears with options)?
I tried this:
document.addEventListener('ontouchstart', function(event)
{
event.preventDefault开发者_如何学Go();
}, false);
You can prevent the finger move(scroll the page) like this:
document.addEventListener('ontouchstart', function(e) {
e.preventDefault();
});
document.body.addEventListener('touchmove', function(e) {
e.preventDefault();
});
And the zoom you just need to adjust the viewport
like this:
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
If you set user-scalable=no, then minimum-scale and maximum-scale are ignored. So if you want to disable zoom, you should use this:
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
精彩评论