【问题标题】:Go to next page when TrueTrue 时跳转到下一页
【发布时间】:2021-10-25 22:45:51
【问题描述】:

JavaScript是这样创建的:如果diction值为true,我想去另一个页面,如果为false,我想让你去首页。我该怎么办?

async function predict() {
    // predict can take in an image, video or canvas html element
    var image = document.getElementById("face-image")
    const prediction = await model.predict(image, false);
    prediction.sort((a,b) => parseFloat(b.probability) - parseFloat(a.probability));
    switch (prediction[0].className){
        case "True":
            resultMessege = "성공"
            break;
        case "False":
            resultMessege = "실패."
            break;
        default:
            resultMessege = "알 수 없는 오류가 발생하였습니다. 다시 시도해보시길 바랍니다."
    }
    $('.result-message').html(resultMessege);

【问题讨论】:

  • 您的意思是为用户重定向页面吗?
  • @AzizaKasenova 是的。我希望你在它为真时转到下一页,在它为假时转到主屏幕。

标签: javascript jquery django


【解决方案1】:

如果重定向到另一个页面是你想要达到的,那么很简单:

window.location.href = '/nextpage';

【讨论】:

  • 如何访问 Django 使用的相应 URL? EX)
  • 据我所知,您可以使用绝对路径“window.location.href = '/nextpage';”。您的 sn-p <a href="{% url 'app:login' %}"> 显示了稍后呈现 url 的快捷方式。我不相信您可以在脚本中使用该快捷方式,因为它只能在 HTML 中使用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-19
  • 2015-03-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多