如何禁止手机浏览器下拉

2025-03-29 18:43:36
推荐回答(4个)
回答1:

  • var overscroll = function(el) {  

  • el.addEventListener('touchstart', function() {  

  • var top = el.scrollTop  

  • , totalScroll = el.scrollHeight  

  • , currentScroll = top + el.offsetHeight;  

  • //If we're at the top or the bottom of the containers  

  • //scroll, push up or down one pixel.  

  • //  

  • //this prevents the scroll from "passing through" to  

  • //the body.  

  • if(top === 0) {  

  • el.scrollTop = 1;  

  • } else if(currentScroll === totalScroll) {  

  • el.scrollTop = top - 1;  

  • }  

  • });  

  • el.addEventListener('touchmove', function(evt) {  

  • //if the content is actually scrollable, i.e. the content is long enough  

  • //that scrolling can occur  

  • if(el.offsetHeight < el.scrollHeight)  

  • evt._isScroller = true;  

  • });  

  • }  

  • overscroll(document.querySelector('.scroll'));  

  • document.body.addEventListener('touchmove', function(evt) {  

  • //In this case, the default behavior is scrolling the body, which  

  • //would result in an overflow.  Since we don't want that, we preventDefault.  

  • if(!evt._isScroller) {  

  • evt.preventDefault();  

  • }  

  • });  

回答2:

document.querySelector('body').addEventListener('touchstart', function (ev) {
    ev.preventDefault();
});

回答3:

document.addEventListener('touchstart',function(event){
event.preventDefault();
});

回答4:

浏览器好像是不可以锁定固定的吧!但是也不会楼主说的向下平移吧!
你试试我用的这款手机QQ浏览器吧!暂时还没发现它可以固定,但是不会向下平移的,
而且本身这款浏览器就是比较好用的,对于年轻人来说,上网的功能很全的,对于上年纪的

人来说,简洁的页面应该也是很不错的,上网浏览速度很快,还节省流量。