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

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

相关推荐
编程零零七1 小时前
Python数据分析工具(三):pymssql的用法
开发语言·前端·数据库·python·oracle·数据分析·pymssql
AI大模型知识分享1 小时前
Prompt最佳实践|如何用参考文本让ChatGPT答案更精准?
人工智能·深度学习·机器学习·chatgpt·prompt·gpt-3
北岛寒沫2 小时前
JavaScript(JS)学习笔记 1(简单介绍 注释和输入输出语句 变量 数据类型 运算符 流程控制 数组)
javascript·笔记·学习
everyStudy2 小时前
JavaScript如何判断输入的是空格
开发语言·javascript·ecmascript
(⊙o⊙)~哦3 小时前
JavaScript substring() 方法
前端
无心使然云中漫步4 小时前
GIS OGC之WMTS地图服务,通过Capabilities XML描述文档,获取matrixIds,origin,计算resolutions
前端·javascript
Bug缔造者4 小时前
Element-ui el-table 全局表格排序
前端·javascript·vue.js
xnian_4 小时前
解决ruoyi-vue-pro-master框架引入报错,启动报错问题
前端·javascript·vue.js
麒麟而非淇淋5 小时前
AJAX 入门 day1
前端·javascript·ajax
2401_858120535 小时前
深入理解MATLAB中的事件处理机制
前端·javascript·matlab