首页 > 解决方案 > 启用滚动触摸 IE

问题描述

在我的网站中,我遇到了这个问题:

如果设备有触摸屏,我希望所有页面都是可滚动的。我的网站遇到了 IE

我尝试touch-action pan-y在我的主要 div 上申请,但没有结果。

标签: htmlinternet-explorermobiletouch

解决方案


将样式添加到 html 文档的头部

<style>.tst{overflow: hidden;}</style>

Add this line in body tag
<body  class="tst" onload ="NoScroll()">

//content here

在脚本标签中添加这个

function noScroll() {
var page = document.getElementsByTagName("body")[0];
if ('ontouchstart' in document.documentElement) {
console.log("touch device detected");
page.classList.remove("tst");
}
else{
console.log("desktop mode");
page.classList.add("tst");
}  
}

推荐阅读