Timed Redirect Function
To do this, place your timed redirect code into a function. Then you can call it with any event handler you like.
Redirecting to Multiple URLs
Modifying our function will enable us to call it from multiple places on the same page (for example, we could call the function from two different buttons - each with a different URL to redirect to).
In order to do this, the change is very simple. All we need to do is tell the function to accept two parameters - one for the URL, and one for the timeout period. We do this by placing the variable names in the brackets, separated by a comma. Like this: