Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Count Down Redirect Uisng JavaScript
<!-- Modify this according to your requirement -->
Redirecting to after <span id="countdown">10</span> seconds
<!-- JavaScript part -->
<script type="text/javascript">
// Total seconds to wait
var seconds = 10;
function countdown() {
seconds = seconds - 1;
if (seconds < 0) {
// Chnage your redirection link here
window.location = "";
} else {
// Update remaining seconds
document.getElementById("countdown").innerHTML = seconds;
// Count down using javascript
window.setTimeout("countdown()", 1000);
// Run countdown function

This comment has been minimized.

Copy link

commented Jul 9, 2018

Worked very nicely. Thanks.


This comment has been minimized.

Copy link

commented Sep 8, 2018

Hi Joel, thank very much for your script which works very well!!!

I have a problem to be solved while using dynamic tracking ID's set up as a suffix in the URL to be added automatically when re-directing. Here is my problem in detail: I use your script is used in my thank-you page and the auto-redirect URL points to an affiliate sales page by setup the corresponding URL in your script.
BUT I need furthermore that the tracking ID suffix from current Page URL of the thank-you page needs to be added as a suffix in the auto-redirect URL dynamically too. (I hope I could have explained in the understandable matter)

Let's say I want to track Facebook ad tracking ID's and forward those dynamically by using your forward script:
The thank-you page with tracking ID from Facebook Ad has then a suffix addon within URL /?tid=cb1wptypid277_fb
(here the full URL example: https://MYDOMAIN/thank-you-cb1/?tid=cb1wptypid277_fb)
The script shall pick up the tracking ID suffix to add this then to the redirecting sales page URL i.e. https://[SalesPage-URL-with-affilate-id-plus-tracking-suffix-from-thank-you-page]/?tid=cb1wptypid277_fb

The idea is, that the script shall pick-up the suffix from current thank-you page URL suffix automatically to use the suffix at the end of the sales page forward URL. This will then solve the proper tracking of corresponding ads.

Any ideas to do this?
Best, Alex


This comment has been minimized.

Copy link

commented Apr 7, 2019

Hi, I like your script. Would you add a button to go to an external link?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.