javascript - 用javascript重定向django url
问题描述
我有 javascript 倒计时计时器,我想在倒计时结束后重定向到另一个页面。countdown 工作完美,但它没有重定向到结果页面
我试过这个:
应用程序.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' %}"
推荐阅读
- tensorflow - 我想在我的自定义层中使用 keras 层,但我无法将层的输出作为张量而不是对象返回
- javascript - 使用 bootstrap-vue 中的传单删除标记单击时弹出的默认对话框
- asp.net-mvc - 有没有办法在 Visual Studio 2019 for Mac 的上下文中获取 ViewBag、Layout 和 Model?
- c# - CryptoStream.Read 的数组边界错误
- video - FFMPEG一开始就卡在00:00:00 speed=0x很长时间
- python - pandas to_excel 如何只合并列?
- docker - Elastic with Kibana on docker 让 Kibana 服务器还没有准备好
- windows - 在 Windows 8 上使用 Get-AppxPackageManifest
- java - 我想知道扫描仪代码在 Java 中是如何工作的
- java - 在 setContentView(R.layout.activity_second) 中,activity_second 为红色