Ad

Redirect Django Url With Javascript

i have countdown timer with javascript, I want to redirect to another page after countdown is over.countdown works pefectly but it's not redirecting to the result page

i tried this:

app.js

var count = 15

var counter = setInterval(timer , 1000)

function timer(){
   count = count-1
   if (count <= 0)
   {
       clearInterval(counter);
       return window.location.replace("{% url'app:result' %}")
   }
   document.getElementById("timer").innerHTML= count + " secs";

}
Ad

Answer

You can use this:

 window.location.href = "{% url'app:result' %}"
Ad
source: stackoverflow.com
Ad