How can I disable page scrolling for a certain time while the preloader is loading in Webflow?

Published on
September 22, 2023

To disable page scrolling for a certain time while the preloader is loading in Webflow, you can use custom code. Follow the steps below:

  1. Add a custom code block: Go to your Webflow project and open the page where you want to disable scrolling. Drag and drop a custom code block to the page. You can find the custom code block under the Add panel on the right-hand side.

  2. Add JavaScript code: Open the settings for the custom code block and switch to the "Before Body" tab. In this tab, you can add JavaScript code that will execute before the body content loads.

  3. Disable scrolling: You can use the following JavaScript code to disable scrolling:

document.body.style.overflow = 'hidden';

This code sets the overflow property of the body element to "hidden", preventing scrolling.

  1. Set a timer: To have the scrolling enabled after a certain time, you can use the setTimeout function in JavaScript. Use the following code to enable scrolling after 3 seconds:
setTimeout(function(){  document.body.style.overflow = 'auto';}, 3000);

This code sets a timer for 3 seconds (3000 milliseconds) before enabling scrolling again by setting the overflow property to "auto".

  1. Publish and test: After adding the code, publish your site and test it to ensure that the scrolling is disabled during the preloader loading. The preloader can be implemented using interactions or custom code depending on your design requirements.

By following these steps, you can effectively disable page scrolling for a certain time while the preloader is loading in Webflow.

Additional Questions:

  1. How can I enable scrolling after a certain time in Webflow?
  2. Can I customize the preloader in Webflow?
  3. What other effects can I apply during the preloader loading in Webflow?