I have a problem that I'm breaking my head to solve.
I'm building an MVC site and would like to make an opening page with Timer rolling like this image:
Solong,beauty.TheproblemisthatIwantitwhenIfinishthiscounteritredirectstothehomepage.HereisthecodefortheView:
<tableclass="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 the page to be redirected to Home by the time it runs out and reaches the opening date 01/10/2016.