-
-
Save Joel-James/62d98e8cb3a1b6b05102 to your computer and use it in GitHub Desktop.
<!-- 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> |
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
Hi, I like your script. Would you add a button to go to an external link?
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
Let me know if this code is incompatible with Google Adsense or will be all good !!
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
Thanks it worked.
Thanks for your awesome script! I just have one question: How to rewrite this code if I want to redirect to the page with the new tab?
You can do that by using window.open('https://duckdev.com', '_blank');
. But this will not work if the popups are blocked.
You can do that by using
window.open('https://duckdev.com', '_blank');
. But this will not work if the popups are blocked.
Thanks!
thank you. its working very nice.
I just wanted to say thank you! I went ahead and made some modifications that suite my needs and thought I'd share them here. I kept my HTML intact just to show a fully working code layout for reference. The script will now get all its variables from the HTML directly so you don't have to update your code in multiple sections when implementing for another project.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>BMRopo: Under Construction</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link rel="preload" as="image" href="images/rocket1.gif" />
</head>
<body>
<div class="col-sm-12 col-xs-7 col-lg-12 commontop text-center"> <!--Using some Bootstrap classes - remove the class or change as required.-->
<h4>Our website is under construction and will be back soon!<br />
<span style="color: #6495ED">
<a id="thewebsite" href="https://www.facebook.com/bmropo/"> <!--Hyperlink used to skip past timer and set the redirect script variable, update for your site.-->
In the meantime, we'll redirect you to our Facebook page <span id="countdown">10</span> <!--The script will use this number for the seconds vaiable.-->
</a>
</span>
</h4>
<script type="text/javascript">
var seconds = document.getElementById("countdown").innerHTML; //Grab the countdown seconds variable from the innerHTML itself for easier adjustments
var website = document.getElementById("thewebsite").href; //The redirect URL will be taken from the skip hyperlink with ID "thewebsite" above.
function countdown() {
if (seconds < -2) { //I'm using a negative number to delay the redirect for a smoother UX transition
window.location = website; //Redirect to the website
} else {
// Update remaining seconds
if (seconds < 1) {document.getElementById("countdown").innerHTML = "now!";} //Phrase used when countdown has reached zero - I'm a stickler for wording!
else if (seconds < 2) {
document.getElementById("countdown").innerHTML = "in " + seconds + " second..."; //Phrase used at the one second mark.
document.getElementById("rocketgif").innerHTML = "<img src=\"images/rocket1.gif\" />";//Show a cool rocket at one second - make sure to preload!
}
else {document.getElementById("countdown").innerHTML = "in " + seconds + " seconds...";}
seconds = seconds - 1; //Reduce the 'seconds' variable
window.setTimeout("countdown()", 1000); //Countdown using javascript
}
}
countdown(); //Run countdown function
</script>
<span id="rocketgif"> </span>
</div>
</body>
</html>
Enjoy!
-- The Dude
Worked very nicely. Thanks.