2
I have a little problem I’m cracking my head to solve.
I am building an MVC website and would like to make a opening page with Timer rolling like this image:
So far, great. The problem is that I want when this counter is over to redirect it to the home page. Follow the View code:
<table class="countdownContainer">
<tr class="info">
<td colspan="4">Contagem Regressiva</td>
</tr>
<tr class="info">
<td id="days">120</td>
<td id="hours">4</td>
<td id="minutes">12</td>
<td id="seconds">22</td>
</tr>
<tr>
<td>Dias</td>
<td>Horas</td>
<td>Minutos</td>
<td>Segundos</td>
</tr>
</table>
<script type="text/javascript">
function countdown(){
var now = new Date();
var eventDate = new Date(2016, 10, 01);
var currentTiime = now.getTime();
var eventTime = eventDate.getTime();
var remTime = eventTime - currentTiime;
var s = Math.floor(remTime / 1000);
var m = Math.floor(s / 60);
var h = Math.floor(m / 60);
var d = Math.floor(h / 24);
h %= 24;
m %= 60;
s %= 60;
h = (h < 10) ? "0" + h : h;
m = (m < 10) ? "0" + m : m;
s = (s < 10) ? "0" + s : s;
document.getElementById("days").textContent = d;
document.getElementById("days").innerText = d;
document.getElementById("hours").textContent = h;
document.getElementById("minutes").textContent = m;
document.getElementById("seconds").textContent = s;
setTimeout(countdown, 1000);
}
countdown();
</script>
<img src="~/Images/Sem Título-1.jpg" class="img-responsive" alt="Em Breve!"/>
I would like that when finished the counter and reached the opening date 01/10/2016, the page was redirected to Home.