gpt4 book ai didi

javascript - 使用javascript重定向django url

转载 作者:行者123 更新时间:2023-12-02 16:39:46 25 4
gpt4 key购买 nike

我有带 javascript 的倒计时计时器,我想在倒计时结束后重定向到另一个页面。倒计时工作正常,但它没有重定向到结果页面

我试过这个:

应用程序.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";

}

最佳答案

你可以使用这个:

 window.location.href = "{% url'app:result' %}"

关于javascript - 使用javascript重定向django url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61929987/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com