Disable vertical scroll in mobile device only fory body (not also for div with overflow: auto)

Viewed 16218

I would like disable vertical scroll in all mobile devices and i found this:

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

that works very well... but in this way i disable scroll also for a div (my menu) that has overflow: auto.

In dekstop browser to avoid anything with JQuery when $(window).scroll() add overflow: hidden to body. And in that way i don't have problem, but with native javascript code yes... i'm new in javascript.

So with jquery i was able disable scroll of body eccept div with overflow: auto, but not with that js code.

I hope you can help me and sorry for my english.

2 Answers
Related