Js-JavaScript-三种弹出提示框-alert-confirm-prompt-ai插件

文章目录

1.alert-提示框

alert (message: string , title: string , errorIcon: Boolean )

Core JavaScript Classes

Displays an alert box

message: Data Type: string

The text to display

title (optional): Data Type: string

The title of the alert; ignored on the Macintosh

errorIcon (optional): Data Type: Boolean , Default Value: false

Display an Error icon; ignored on the Macintosh

弹出一个提示框,只有一个确定按钮。

javascript 复制代码
alert("知了插件");

如下图所示:

2.confirm-确认框

confirm (message: string , noAsDefault: Boolean , title: string ): Boolean

Core JavaScript Classes

Displays an alert box with Yes and No buttons; returns true for Yes

message: Data Type: string

The text to display

noAsDefault (optional): Data Type: Boolean , Default Value: false

Set to true to set the No button as the default button

title (optional): Data Type: string

The title of the alert; ignored on the Macintosh

弹出一个确认框,选择Yes返回true,选择No放回false。

javascript 复制代码
function test(){
    var rlt=confirm ("是否继续?", true, "提示");
    $.writeln (rlt);
}
test();

如下图所示:

3.prompt-输入框

prompt (prompt: string , default: string , title: string ): string

Core JavaScript Classes

Displays a dialog allowing the user to enter text

Returns null if the user cancelled the dialog, the text otherwise

prompt: Data Type: string

The text to display

default (optional): Data Type: string

The default text to preset the edit field with

title (optional): Data Type: string

The title of the dialog;

用户取消返回null,确认返回对应文本对象。

javascript 复制代码
function test(){
    var rlt=prompt ("输入宽度:", "10", "提示");
    $.writeln (rlt);
}
test();

如下图所示:

4.总结

通过这三种方式,可以简单实现与程序的交互控制。

相关推荐
计算机魔术师6 分钟前
OpenAI 首个踩红线的 AI 模型来了:能自己挖漏洞,但只给少数人用
前端
闲坐含香咀翠7 分钟前
从 132MB 到 25MB:列式存储怎么把 CPU 缓存命中率提上去的
前端·数据结构·性能优化
闲坐含香咀翠17 分钟前
把 AntV S2 列头计算从 O(n²) 降到 O(n):一次开源组件的性能改造
前端·性能优化
闲坐含香咀翠22 分钟前
Worker 常驻 + 零拷贝:postMessage 的结构化克隆算法与 Transferable 的真实代价
前端·性能优化
JunjunZ34 分钟前
Naive UI 虚拟级联选择器适配 Element Plus 风格
前端·javascript·vue.js
ynchyong1 小时前
微信小程序启动顺序遇到的一个坑
前端·微信小程序
用户233376852181 小时前
接口卡死排查实录-缺失return的UB死循环
前端·后端
光影少年2 小时前
如何实现RN 多环境、多渠道打包
前端·react native·react.js
闲坐含香咀翠2 小时前
百万行数据透视表,我是怎么把 Vue 响应式开销砍到零的
前端·vue.js·性能优化