I'm trying to make a dynamic function that makes redirects but it doesn't work It returns me 'undefined'
here is the HTML code:
<p>You will be redirected to the page X in <span id="time">4</span> seconds..</p>
here is the JavaScript code:
var seconds;
var temp;
function countdown(page) {
seconds = document.getElementById('time').innerHTML;
seconds = parseInt(seconds, 10);
if (seconds == 1) {
temp = document.getElementById('time');
temp.innerHTML = '0. If you are not, please click <a href="' + page + '">here</a>.';
window.location = page;
return;
}
seconds--;
temp = document.getElementById('time');
temp.innerHTML = seconds;
timeoutMyOswego = setTimeout(countdown, 1000);
}
countdown('/asimplepage/asdfgh.html');
I tried also to do:
function redirect(page){
window.location = page;
}
redirect('thisworks.html');