0
我有這段代碼。它運行良好,但如果在第一次彈出時單擊CANCEL,該框將繼續運行。我不知道如何讓它進入下面的頁面,如果我第一次點擊取消彈出。javascript alert box取消
var numero= prompt ("introduce un numero")
var resultado= parImpar(numero);
alert ("el numero "+numero+" es "+resultado);
function parImpar (numero){
if (numero %2===0) {
return "par" ;
}
else{
return "impar" ;
}
}
if (window.confirm ("Probemos otro numero ")){
var numero= prompt ("Elegi");
var resultado =parImpar (numero);
alert("El numero "+numero+" es "+resultado);
}else{
}
body {
background-color:pink;
}
h1 {
font-weight:bold;
}
p{
font-weight:bolder ;
font-family: Garamond;
}
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>First web! </h1>
<p>Hi everyone! this is mi first ever page/program. I have been learning for a month now and i need it to understand some javascript functions. Im really fighting with them.</p>
</body>
</html>
謝謝!現在我有另一個問題。現在它不返回「null」,但它彈出第二個提醒,我不想要那個。我希望在第一次取消點擊時,它直接到第 –
@NanaRepetto,然後在if里加上if(window.confirm(「Probemos otro numero」)){...} if(numero!= null ){...}也是。 –