body.style.overflow = 'hidden' when the modal opens and remove it when the modal closes. You're encountering scrolling issues in a modal where the background page continues to scroll after opening it, especially when using Finsweet’s Cookie Consent or other parameter-based logic.
?show-modal=true), Webflow may not automatically disable body scrolling.
overflow: hidden on Body
<body> element in interactions.body-scroll-lock method or custom JS to manually disable scrolling.
<script>
const modal = document.querySelector('.modal-class'); // Update with your modal's class
const body = document.body;
if (modal && modal.classList.contains('w--open')) {
body.style.overflow = 'hidden';
}
modal?.addEventListener('click', (e) => {
if (e.target.classList.contains('close-button-class')) { // Update with your close button’s class
body.style.overflow = '';
}
});
</script>
.modal-class to your actual modal wrapper class.overflow: hidden is set when the modal is open and removed when closed.
fs-cc, fs-param), trigger scroll-lock using a similar condition.
<script>
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get("show-modal") === "true") {
document.body.style.overflow = 'hidden';
// Optionally open the modal here if not already
}
</script>
overflow: hidden class on <body>’s proxy (e.g., add a custom overflow-hidden-body class), and control it using Finsweet’s @set or interactions.
To fix the scrolling issue when using modals with Finsweet cookies or URL parameters, manually disable body scroll by setting body.style.overflow = 'hidden' when the modal opens, and revert it when closed. Use custom JS to handle this dynamically, especially for conditions triggered by parameters like ?show-modal=true.