Instantly share code, notes, and snippets.

Embed
What would you like to do?
Count Down Redirect Uisng JavaScript
<!-- 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.

jamesnotjim commented Jul 9, 2018

Worked very nicely. Thanks.

@wci-aw

This comment has been minimized.

wci-aw 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment