window.onload = function() {
// 阻止双击放大
var lastTouchEnd = 0;
document.addEventListener("touchstart", function(event) {
if (event.touches.length > 1) {
event.preventDefault();
}
});
document.addEventListener(
"touchend",
function(event) {
var now = new Date().getTime();
if (now - lastTouchEnd <= 300) {
event.preventDefault();
}
lastTouchEnd = now;
},
false
);
// 阻止双指放大
document.addEventListener("gesturestart", function(event) {
event.preventDefault();
});
//ios浏览器地址栏隐藏
var u = navigator.userAgent;
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
if (isiOS) {
window.οnlοad = function() {
if (
document.documentElement.scrollHeight <=
document.documentElement.clientHeight
) {
bodyTag = document.getElementsByTagName("body")[0];
bodyTag.style.height =
(document.documentElement.clientWidth / screen.width) *
screen.height +
"px";
}
setTimeout(function() {
window.scrollTo(0, 1);
}, 0);
};
document.onfullscreenchange = e => {
//你的逻辑代码
// return
this.isFullscreen = !this.isFullscreen;
console.log(e);
};
}
};
//监听横竖屏
window.addEventListener("orientationchange", function(event) {
if (window.orientation == 180 || window.orientation == 0) {
// alert("竖屏");
} else if (window.orientation == 90 || window.orientation == -90) {
// alert("横屏");
}
});
//浏览器可视区宽高
document.body.style.overflow = "hidden";
window.onresize = () => {
that.innerHeight = window.innerHeight;
that.innerWidth = window.innerWidth;
};
h5浏览器处理
最新推荐文章于 2024-05-06 11:47:15 发布