Disabling Scrolling in Mobile Browsers using JavaScript

To disable scrolling in modern mobile browsers (e.g., iOS) using JavaScript, you can use the following code:

function preventDefault(e){

function disableScroll(){
    document.body.addEventListener('touchmove', preventDefault, { passive: false });

function enableScroll(){
    document.body.removeEventListener('touchmove', preventDefault);

By using the disableScroll() function, scrolling will be disabled. If you want to enable scrolling again, you can use the enableScroll() function.