鍍金池/ 問答/C++  HTML/ 如何取消微信web頁面頂部下拉后出現(xiàn)黑色的底部?

如何取消微信web頁面頂部下拉后出現(xiàn)黑色的底部?

如題:

clipboard.png
如何禁止如圖中出現(xiàn)的內(nèi)容?有沒有知道的大神

回答
編輯回答
誮惜顏

1.可以給document的touchmove事件禁止掉就行了

document.querySelector('body').addEventListener('touchmove', function(e) {
        e.preventDefault();
    })

2.如果頁面有部分區(qū)域必須需要滑動,需要用touchmove事件的話,那么可以把那部分的touchmove事件過濾掉

比如我想要以下代碼中的bottom類可以用touchmove事件

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>微信禁止下拉露黑底</title>
</head>
<body>
    <div class="top"></div>
    <div class="bottom"></div>
</body>
</html>

用以下代碼就可以實現(xiàn)

document.querySelector('body').addEventListener('touchmove', function(e) {
    if (!document.querySelector('.bottom').contains(e.target)) {
        e.preventDefault();
    }
})
 

2017年7月23日 08:35
編輯回答
任她鬧

無法禁止,就像android chrome瀏覽器無法禁止頁面整體下拉刷新

2017年7月30日 21:13