Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!-- Modify this according to your requirement -->
<h3>
Redirecting to duckdev.com after <span id="countdown">10</span> seconds
</h3>
<!-- 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 = "https://duckdev.com";
} else {
// Update remaining seconds
document.getElementById("countdown").innerHTML = seconds;
// Count down using javascript
window.setTimeout("countdown()", 1000);
}
}
// Run countdown function
countdown();
</script>
@jamesnotjim

This comment has been minimized.

Copy link

commented Jul 9, 2018

Worked very nicely. Thanks.

@wci-aw

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

@nicovoni

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?

@laythjawad

This comment has been minimized.

Copy link

commented Jul 10, 2019

I've created an account here so I can comment
And I say thank you very much
I have always been looking for this and have not found it anywhere
Thank you so much & Thank you so much & Thank you so much

@laythjawad

This comment has been minimized.

Copy link

commented Jul 10, 2019

Let me know if this code is incompatible with Google Adsense or will be all good !!

@laythjawad

This comment has been minimized.

Copy link

commented Jul 11, 2019

I want to make it when the countdown ends. open a new tag and I do not want redirection to be redirected on the same page
How can I reroute with a new tag popup and stay on the same site page

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.