当前位置:网站首页>alter和confirm,prompt的区别
alter和confirm,prompt的区别
2022-07-28 04:38:00 【今天不学习,明天变腊鸡】
alter和confirm的区别
1.理论知识:
a. alter:弹出警告框,只能够确认alert("这是一个警告框");
b. confirm弹出确认框,有两个按钮:确定和取消,分别返回true和falseconfirm("这是一个确认框,确定返回true,取消返回false");
c. prompt弹出提示框,确定,取消,输入框,确定返回输入框的值(不输入为空""),取消返回Nullprompt("这是一个提示框,确定返回输入值,取消返回Null","输入框内默认文本");
2.实践
<!DOCTYPE html>
<html>
<head>
<title>弹出框测试</title>
</head>
<body style="text-align: center;">
<h1>弹出框测试</h1>
<button onclick="test_1()">警告框</button>
<button onclick="test_2()">确认框</button>
<button onclick="test_3()">提示框</button>
<p id="demo"></p>
</body>
<script> function test_1(){
alert(("这是一个警告框")); }//点击警告框会提出警告,确认后向下执行 function test_2(){
test2 = confirm("这是一个确认框,确定返回true,取消返回false"); document.getElementById("demo").innerHTML = test2; }//点击确认框会提出警告,确认后向下执行,否则不向下执行 function test_3(){
var test3 = prompt("这是一个提示框,确定返回输入值,取消返回Null","输入框内默认文本"); document.getElementById("demo").innerHTML = test3; }//点击提示框会提出警告,确认后向下执行,否则不向下执行,输入的类容返回给test3; </script>
</html>
边栏推荐
- 网页源代码查看竟然有这么多方法!你都知道吗?
- Power consumption: leakage power
- 重要的 SQL Server 函数 - 日期函数
- Campus stray cat information recording and sharing applet source code
- Sort - cardinal sort
- 高数_第4章__曲线积分_习题解法
- What is the account opening process of qiniu business school? Is it safe?
- High number_ Chapter 4__ Curvilinear integral_ Exercise solution
- How much does it cost to build a self built server for ark survival evolution?
- 【sylar】框架篇-Chapter21-环境变量模块
猜你喜欢

MySQL数据库————初识数据库

Practice and thinking of AI standardization engine in pink client

DNS series (III): how to avoid DNS spoofing
![[II. Mobile web page development] 2D & 3D conversion and animation, mobile terminal layout, responsive layout](/img/9a/a3b36aa2e5bf53d9f8355ea3c18f1e.png)
[II. Mobile web page development] 2D & 3D conversion and animation, mobile terminal layout, responsive layout

重要的 SQL Server 函数 - 数字函数

Full resolution of the use of go native plug-ins

Information system project manager (2022) - key content: Information System Security Management (20)

高数_第4章__曲线积分_习题解法

ADB environment configuration

Use animatedbuilder to separate components and animation, and realize dynamic reuse
随机推荐
重要的 SQL Server 函数 - 数字函数
Campus stray cat information recording and sharing applet source code
重要的 SQL Server 函数 - 日期函数
Idea2022 change the local warehouse and configure Alibaba cloud central warehouse
【sylar】框架篇-Chapter6-协程调度模块
校园流浪猫信息记录和分享的小程序源码
DNS series (III): how to avoid DNS spoofing
The unsatisfied analysis of setup and hold timing is the solution
关系数据库事务中的对象锁定
Web渗透之域名(子域名)收集方法
Internet of things industrial serial port to WiFi module wireless routing WiFi module selection
网页源代码查看竟然有这么多方法!你都知道吗?
[Sylar] framework chapter -chapter21- environment variable module
Advanced architects, 16 common principles of microservice design and Governance
[Sylar] framework Chapter 6 collaborative scheduling module
【sylar】框架篇-Chapter11-Socket 模块
【sylar】框架篇-Chapter21-环境变量模块
set与list性能对比
Strlen introduction, and the difference between sizeof
Constructor of member function