Site logo

Archived topic

Page redirect after a certain amount of time

3 replies · Started by Mike on May 21, 2021

Viewing posts 1–4 of 4

I'm setting up forms on a website and when the form is submitted, I'm redirecting them to a contact thank you page. How can I make that page then redirect back to the home page after a certain amount of time, say 5 seconds?

I saw this code here, but not sure where and how to implement it. https://www.tutorialspoint.com/How-to-use-JavaScript-to-redirect-a-webpage-after-5-seconds

Not sure if this is GeneratePress specific enough for support, if not no worries about deleting it!

Thanks!

Mike

Hi there,

try using the code that topic provided:

1. Create a new Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/

2. Add the script to the Hook text area:

<script>
setTimeout(function(){
    window.location.href = 'https://www.tutorialspoint.com/javascript/';
}, 5000);
</script>

Change the href to your home page.

3. Set the Hook to: wp_head
4. Set the Display Rules > Location to your thank you page.

Thank you David! Perfect!

Glad to be of help.

This archived topic is closed to new replies.