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.总结

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

相关推荐
IMPYLH几秒前
HTML 的 <tr> 元素
前端·html
行者全栈架构师8 分钟前
【鸿蒙心迹】ArkUI 列表性能实战——为什么 200 条数据页面掉到 20fps,LazyForEach 怎么救(HarmonyOS 7.x)
前端·算法·架构
vx_Biye_Design13 分钟前
flask学生课程笔记共享系统29026-计算机课程设计、毕业设计
java·javascript·spring boot·后端·elasticsearch·flask·课程设计
派小心.22 分钟前
热力图工具的多页面管理功能怎么比?
前端·数据分析
OpsEye38 分钟前
上线大模型只是第一步,用好 AI 离不开完整的成本管控
javascript·ai编程
爱勇宝43 分钟前
裁员裁掉了那个干了14年的人:我这才看清职场的5条潜规则
前端·后端·程序员
Hilaku1 小时前
GraphQL 在国内为什么水土不服?
前端·javascript·程序员
Latchh1 小时前
PDF打开不要密码却显示已加密,前端怎么判断
前端·图像处理·人工智能·计算机视觉·pdf
秋天的一阵风1 小时前
🧐 为什么大厂 RAG 从不用纯向量检索?
前端·面试·ai编程
恋猫de小郭1 小时前
Flutter + EmbeddingGemma 2,谷歌发布完全端侧的 AI Edge Foresight
android·前端·flutter