Webflow sync, pageviews & more.
NEW

Is there a way to auto-scroll the page in Webflow after a certain amount of time, without the script automatically scrolling back up if the user has already scrolled past the designated point?

TL;DR
  • Add a delayed scroll using setTimeout in Webflow’s page settings (before tag).
  • Check if the user hasn't scrolled past the target position using window.scrollY before triggering smooth scroll.
  • Customize the scroll target using a fixed pixel value or an element's offsetTop, ensuring the element is loaded before scrolling.

You can auto-scroll a Webflow page after a delay using custom JavaScript, but you’ll need to add logic to prevent the scroll if the user already scrolled past the target position.

1. Add a Page Trigger Delay

  • Use custom code to delay the scroll (e.g., wait 3 seconds before scrolling).
  • This is done using setTimeout() inside a script added to your Page Settings › Before body tag.

2. Check Current Scroll Position

  • Before scrolling, check if the user has already scrolled past the point you want to scroll to using window.scrollY.
  • Example: If you want to scroll to 500px, only scroll if window.scrollY < 500.

3. Add Custom Script in Webflow

  • Go to Page Settings › Before tag.
  • Add the following custom code (wrapped in <script> tags):
<script>  window.addEventListener("load", function () {    setTimeout(function () {      var targetScrollY = 500; // change this to your desired scroll pixel value      if (window.scrollY < targetScrollY) {        window.scrollTo({          top: targetScrollY,          behavior: "smooth"        });      }    }, 3000); // delay in milliseconds  });</script>

4. Customize Scroll Target

  • Instead of scrolling to a fixed pixel value, you can scroll to a specific section using its element ID:
  • Use document.getElementById("your-target-id").offsetTop to get the target position.
  • Updated line inside the script:
var targetScrollY = document.getElementById("section2").offsetTop;

5. Apply Lazy Load Caution (Optional)

  • If your target section loads lazily or based on interactions, make sure the target element exists and is fully rendered when the script runs.
  • You may use setTimeout with a slightly longer delay, or requestAnimationFrame/MutationObserver if needed.

Summary

To auto-scroll in Webflow after a delay without affecting users who already scrolled past, use JavaScript with a setTimeout() and a conditional window.scrollY check. Add this logic in the page’s custom code section to control exactly when and where the page scrolls.

Rate this answer

Other Webflow Questions