I have this javascript redirect script which works
<p>You will be redirected in <span id="counter">120</span> second(s).</p>
<script type="text/javascript">
function countdown() {
var i = document.getElementById('counter');
if (parseInt(i.innerHTML)<=0) {
location.href = 'http://example.com';
}
i.innerHTML = parseInt(i.innerHTML)-1;
}
setInterval(function(){ countdown(); },1000);
</script>
My question is: How can I get a random number (e.g. between 60 and 120) instead of a fixed number before the script redirects?
Aucun commentaire:
Enregistrer un commentaire