I’d like to make a certain WordPress page pause for a few seconds before redirecting back to the page the visitor was on. The scenario is a redirect page after successful submission of a form. It will say ‘form submitted successfully’ or the like for a few seconds, and then redirect back to the page the visitor was on. The redirect is just a simple browser back functionality —
<script type="text/javascript">history.go(-1);</script>
— in the head, which is easy to add to just that specific page with a custom field. But what can I add to make the page pause for a few seconds before going back? Bear in mind that this is a WordPress site with lots of posts so I can’t use some kind of body onload redirect back to a specific post with window.location = "the-post-or-page-visitor-was-on";. I need to use the browser’s back history to just take the visitor back -1 to whatever page or post they were on, but just pause for a few seconds before doing so.
Thanks a lot.
Try
window.setTimeout():