簡體   English   中英

為什么我的代碼沒有在 javascript 中顯示確認彈出窗口?

[英]Why my code doesn´t display a confirm popup in javascript?

我在鏈接到 html 表單的腳本中具有以下功能。 當一切正常時,導航器應該創建 3 個 cookie 並顯示一個確認彈出窗口,但它不顯示確認彈出窗口,但它創建了 cookie。 我曾在 Firefox 中嘗試過,但我沒有在 chrome 中進行過,因為它確實可以用 cookie 來擴展事物,所以我更喜歡 Firefox

我是 stackoverflow 的新手,所以任何建議都將不勝感激

PD:代碼的某些部分是西班牙語(valor=value nombre=name contraseña=password)

function checkForm() {
  var emailValue = document.getElementById("email").value;
  var nombreValue = document.getElementById("nombre").value;
  var passValue = document.getElementById("pass1").value;
  if(comprobarCookie("email", emailValue)==false){
  if (CheckPass()) {//si las contraseñas coinciden, creamos la cuenta
    createCookie("email", emailValue);
    createCookie("nombre", nombreValue);
    createCookie("pass", passValue);
    var confirm=confirm("!Tu cuenta ha sido creada con éxito!")
    if (confirm==true) {
      location.replace("https://www.w3schools.com")
    } else {
      txt = "No has creado la cuenta";
    }
  } else {
    alert("las contraseñas no coinciden")
  }
  }else{
    alert("Ya existe una cuenta con ese email")
  }
}

看起來您正在使用保留字confirm作為要測試的變量。 嘗試更換:

 var confirm=confirm("!Tu cuenta ha sido creada con éxito!")
if (confirm==true) {
  location.replace("https://www.w3schools.com")
} else {
  txt = "No has creado la cuenta";
}

var user_clicked = confirm("!Tu cuenta ha sido creada con éxito!");
if (user_clicked === true) {
  location.replace("https://www.w3schools.com");
} else {
  txt = "No has creado la cuenta";
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM