Disable Scroll for Webflow
Learn how to easily disable and enable page scroll in Webflow when your mobile menu is open. Includes a simple JavaScript snippet and insights on Finsweet's solution—perfect for small business websites.
.jpg)
Disabling page scroll when your mobile navigation menu is open is a must for a smooth user experience. While Finsweet’s solution is feature-packed and works well for many Webflow sites—especially small businesses—it can be tricky to set up for something as simple as toggling scroll on your hamburger menu. If you just want a lightweight fix, here’s an easy script you can add in seconds—and best of all, you don’t need to maintain or update this code at all. Just set it up once and forget about it.
How It Works
When users tap the hamburger menu, this script toggles overflow: hidden
on the <body>
to disable scrolling, then re-enables it when the menu closes.
Where to add the code:
Paste the script before the closing </body>
tag in your Webflow project’s custom code settings or directly on the page. This ensures the script runs after the page content has loaded.
<script>
document.addEventListener('DOMContentLoaded', () => {
const navWrap = document.querySelector('.nav_mob_wrap');
navWrap.addEventListener('click', () => {
// Delay to let Webflow toggle its open class
setTimeout(() => {
const isOpen = navWrap.classList.contains('w--open');
document.body.style.overflow = isOpen ? 'hidden' : '';
}, 50);
});
});
</script>
Just update .nav_mob_wrap
to match your menu wrapper class. Publish, and you’re done! No ongoing maintenance required.

Frequently Asked Questions
Where should I add this script in Webflow?
Add the script just before the closing </body>
tag in your project’s custom code area, or directly on the page if you only want it to run there. This ensures it works after all your content and menu elements have loaded.
Do I need to maintain or update this code over time?
Nope—this script is “set it and forget it.” Once you add it to your Webflow project and connect it to the right class, there’s no need for updates or maintenance. It just works in the background.
What class name should I use for the script?
Change .nav_mob_wrap
in the script to match the class of your menu wrapper or hamburger button in Webflow.
Will this affect SEO or accessibility?
No, this only affects the scroll behavior when the menu is open and won’t impact SEO or accessibility, as long as you maintain standard Webflow navigation best practices.
Where exactly should I add this script in Webflow?
To make this script work across your entire site, go to your Webflow Site Settings and paste the code into the “Before </body> tag” section. This way, scroll will be disabled on every page whenever the nav menu is open. If you only want to disable scroll on a single page, add the script to that page’s custom code area instead.