Is there a code in Webflow that can automatically redirect an idle page back to the Home page after a certain period of time?

TL;DR
  • Insert custom JavaScript code in Webflow's page settings to detect inactivity and auto-redirect to the Home page using window.location.href after a set inactivity period.
  • Adjust the timeout period in milliseconds to match preferred idle time, publish your site, and test the feature to ensure it functions correctly.

If you want to auto-redirect an idle page back to the Home page after a specific time, here’s how you can achieve this using Webflow's Custom Code feature.

1. Insert Custom Code

  • Go to the Page Settings of the page that needs the redirection.
  • Scroll down to the Custom Code section.

2. Add Idle Detection Script

  • Insert the following script in the Before </body> tag section:
  • Use JavaScript to detect inactivity and redirect: 
    • Set a timeout function to redirect after a certain period of inactivity (e.g., 5 minutes).
    • Use setTimeout() to define idle time (e.g., 300,000 milliseconds for 5 minutes).
    • Redirect the page using window.location.href.

3. Adjust Time for Redirection

  • Modify the timeout period in the script based on your preferred inactivity duration:
  • Convert minutes to milliseconds as needed for the time delay.

4. Test the Feature

  • Publish your Webflow site to see the changes.
  • Navigate to the page, remain idle, and ensure automatic redirection to the Home page occurs after the specified time.

5. Update As Necessary

  • Monitor feedback from users.
  • Adjust the idle time or implementation based on any user experience concerns.

Summary

To auto-redirect an idle page back to the Home page in Webflow, use custom JavaScript code in the page settings to detect inactivity and utilize the window.location.href function for redirection after a set period.

Rate this answer

Other Webflow Questions