জেভাস্ক্রিপ্ট পপআপ

JavaScript has three types of pop-up boxes: warning boxes, confirmation boxes, and prompt boxes.

Warning box

To ensure that information is passed to the user, the warning box is usually used.

When the warning box appears, the user will need to click "OK" to continue.

NULL

window.alert("window.prompt("defaultText

window.alert(); window.prompt() 方法可以不带 to write the prefix.

alert("I am a warning box!");

alert("Hello\nHow are you?");

Confirmation box

If you want the user to verify or accept something, you usually use the "confirmation" box.

When the confirmation box appears, the user will have to click "OK" or "Cancel" to continue.

If the user clicks "OK", the box returns trueIf the user clicks "Cancel", the box returns falsen

NULL

window.confirm("window.prompt("defaultText

window.confirm(); window.prompt() 方法可以不带 window

var r = confirm("Please click the button");
if (r == true) {
    x = "您按了确认!";
x = "您按了确认!";
    } else {
document.getElementById("demo").innerHTML = "你好 " + person + "!今天过的怎么样?";

alert("Hello\nHow are you?");

x = "您按了取消!";

提示框

如果您希望用户在进入页面前输入值,通常会使用提示框。

当提示框弹出时,用户将不得不输入值后单击“确定”或点击“取消”来继续进行。 如果用户单击“确定”,该框返回输入值。如果用户单击“取消”,该框返回n

NULL

语法window.prompt("sometext","defaultText

"); window.prompt() 方法可以不带 window

前缀来编写。
var person = prompt("请输入您的姓名", "比尔盖茨");
    if (person != null) {
document.getElementById("demo").innerHTML = "你好 " + person + "!今天过的怎么样?";

alert("Hello\nHow are you?");

}

নিউলাইন যদি প্রস্তুতপ্রদর্শনীতে ফিল্ডটি বানার জন্য নিউলাইন দিতে হলে, তবে রিভার্স স্ল্যাশের পরে একটি অক্ষর যোগ করুনn

ইনস্ট্যান্স

alert("Hello\nHow are you?");