js中的对话框事通过调用window对象的alert()  confirm()  和 prompt()来获得,完成人机交互。

1. 警告框alert()

function alert(){
    // 弹出提示语,无返回值
    alert("警告");
}

2.确认框confirm()

function confirm(){
    //点击确定返回true,点击取消返回false
    
    if(confirm("确定点击吗?")){
         alert("恭喜点击成功")
    }

}

3.提示框prompt()

function prompt(){
    //弹出对话框,输入文字,可以提交
    var text = prompt("请输入");
    if(text){
        alert("输入的内容为:"+ text)
    }
}

 

相关文章:

  • 2021-05-27
  • 2022-12-23
  • 2022-02-08
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
猜你喜欢
  • 2021-06-20
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案