Reputation: 23
what i need is:
Now, this is my code
<script type="text/javascript">
function DownloadAndRedirect()
{
var DownloadURL = "url-of-the-file";
var RedirectURL = "url-of-thank-you-page";
var RedirectPauseSeconds = 2;
location.href = DownloadURL;
setTimeout(DoTheRedirect(+RedirectURL+),parseInt(RedirectPauseSeconds*1000));
}
function DoTheRedirect(url) { window.location=url; }
</script>
Can you provide the correct code? i know i can use window.open...but how?
Thanks
Upvotes: 2
Views: 1089
Reputation: 14570
You are not using the setTimeout
correctly. You need to pass the thanksyou
page url and set the seconds to 2000
which are equivalent to 2
seconds.
In setTimeout
use window.open
with a target _blank
so that it opens in a new tab
.
Live Demo: (Code tested and its working on localhost)
function DownloadAndRedirect() {
var DownloadURL = "https://www.google.com/";
var RedirectURL = "https://www.google.com/";
location.href = DownloadURL;
setTimeout(function() {
window.open(RedirectURL, '_blank')
}, 2000)
}
DownloadAndRedirect()
Upvotes: 1