1

What would be causing the script below to not prevent the body from scrolling on iOS when prompted on click? Is there something I've missed, in terms of implementing this?

NOTE: This is not a working snippet, just condensed examples of the script and some CSS styles:

$(document).ready(function() {
  $("a.open").click(function() {
    $('body').addClass('no-scroll');
    $('body').bind('touchmove', function(e) {
      e.preventDefault();
    });
  });
  $("a.close").on("click", function(s) {
    $('body').removeClass('no-scroll');
    $('body').unbind('touchmove');
  });
});
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  z-index: 0;
}

body.no-scroll {
  overflow: hidden !important;
  -webkit-overflow-scrolling: auto;
  height: auto !important;
}
nrweb
  • 211
  • 3
  • 15

0 Answers0