Javascript:alert()、prompt()、confirm()

alert()

alert("Hello! I am an alert box!!");

prompt()

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

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

confirm()

var txt;
var r = confirm("Press a button!");
if (r == true) {
    txt = "You pressed OK!";
} else {
    txt = "You pressed Cancel!";
}
本篇發表於 Javascript。將永久鏈結加入書籤。

回應已關閉。