// The confirm function is used to display a dialog with ok and cancel. Usage:
var content = confirm("Hello"); // The "hello" means to show the following text
if (content === true) {
// Do whatever if the user clicked ok.
} else {
// Do whatever if the user clicks cancel.
}
// You can also use window.confirm()
if (window.confirm("Une nouvelle fenêtre va s'ouvrir.")) {
window.open("fenetre.html", "Nouvelle fenêtre", "");
}
if (window.confirm("Do you really want to leave?")) {
window.open("exit.html", "Thanks for Visiting!");
}
onclick="if (! confirm('Deseja mesmo deletar o arquivo links.html?')) { return false; }"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>confirm</title>
</head>
<script>
function confirm() {
confirm("Alert")
}
</script>
<body>
<button onclick="confirm()">confirm</button>
</body>
</html>