When IOS clicks on text input boxes such as Input and textarea to focus on focus (), the page will be enlarged as a whole
Using meta settings, add a meta tag that prohibits scaling to the head.
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
JS Code `
//当页面加载完成后触发该函数
//This function is triggered when the page is loaded.
window.onload = function () {
//e.preventDefault() --- 阻止默认事件
//当一个手指放在屏幕上时,会触发touchstart事件。如果另一个手指又放在了屏幕上,则会先触发gesturestart事件,随后触发基于该手指的touchstart事件。
//When a finger is placed on the screen, the touchstart event will be triggered. If another finger is placed on the screen again, the gesturestart event will be triggered first, and then the touchstart event based on that finger will be triggered.
document.addEventListener('gesturestart', function (e) {
e.preventDefault();
});
//在单个元素上单击两次 --- dblclick
document.addEventListener('dblclick', function (e) {
e.preventDefault();
});
//一个手指放在屏幕上时,会触发touchstart事件
//touchstart event will be triggered when a finger is placed on the screen.
document.addEventListener('touchstart', function (event) {
if (event.touches.length > 1) {
event.preventDefault();
}
});
//如果一个或两个手指在屏幕上滑动,将会触发gesturechange事件
//If one or two fingers slide on the screen, the gesturechange event will be triggered.
//但只要有一个手指移开,则会触发gestureend事件,紧接着又会触发toucheend事件。
//But whenever one finger moves away, the gestureend event will be triggered, followed by the toucheend event.
var lastTouchEnd = 0;
document.addEventListener('touchend', function (event) {
var now = (new Date()).getTime();
if (now - lastTouchEnd <= 300) {
event.preventDefault();
}
lastTouchEnd = now;
}, false);
};
`