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

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

相关推荐
toooooop86 分钟前
本地开发环境webScoket调试,保存html即用
前端·css·websocket
山有木兮木有枝_13 分钟前
手动封装移动端下拉刷新组件的设计与实现
前端
阳光阴郁大boy14 分钟前
大学信息查询平台:一个现代化的React教育项目
前端·react.js·前端框架
小菜全21 分钟前
uniapp新增页面及跳转配置方法
开发语言·前端·javascript·vue.js·前端框架
AlexMercer101223 分钟前
[前端]1.html基础
前端·笔记·学习·html
白水清风32 分钟前
关于Js和Ts中类(class)的知识
前端·javascript·面试
前端Hardy34 分钟前
只用2行CSS实现响应式布局,比媒体查询更优雅的布局方案
javascript·css·html
小菜全42 分钟前
uniapp基础组件概述
前端·css·vue.js·elementui·css3
小天呐1 小时前
qiankun 微前端接入实战
前端·js·微前端
周航宇JoeZhou1 小时前
JP4-7-MyLesson后台前端(五)
java·前端·vue·elementplus·前端项目·mylesson·管理平台