предупреждение подтвердите приглашение JavaScript
if (confirm("Press a button!")) {
console.log("Accepted")
} else {
console.log("Declined")
}
Undefined
if (confirm("Press a button!")) {
console.log("Accepted")
} else {
console.log("Declined")
}
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var name = prompt("Please enter your name", "XYZ");
if (name != null) {
alert('Your name is ' + name )
}
}
</script>
</body>
</html>