javascript function confirm code example

Example 1: a href confirm javascript

<a href="delete.php?id=22" onclick="return confirm('Are you sure?')">Link</a>

Example 2: javascript prompt

var person = prompt("Please enter your name", "Harry Potter");

if (person != null) {
  document.getElementById("demo").innerHTML =
  "Hello " + person + "! How are you today?";
}

Example 3: javascript alert

alert("string");

Example 4: confirm javascript

if (window.confirm("Une nouvelle fenêtre va s'ouvrir.")) {
    window.open("fenetre.html", "Nouvelle fenêtre", "");
}

Tags:

Php Example