Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
161
rated 0 times [  164] [ 3]  / answers: 1 / hits: 16771  / 8 Years ago, fri, march 11, 2016, 12:00:00

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.


More From » jquery

 Answers
12

i solved always with jQuery:



when i want disable scroll add:



    $(body).css({overflow:hidden,'position':'fixed'});


with body: fixed i'm sure that also with mobile device is impossible scroll the page (except div that has overflow: auto


[#62977] Wednesday, March 9, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
isaacvalentinn

Total Points: 325
Total Questions: 120
Total Answers: 131

Location: North Korea
Member since Tue, Jun 16, 2020
4 Years ago
isaacvalentinn questions
Mon, Jan 18, 21, 00:00, 3 Years ago
Mon, Nov 23, 20, 00:00, 4 Years ago
Wed, Sep 23, 20, 00:00, 4 Years ago
;