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

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

相关推荐
zwjapple18 分钟前
docker-compose一键部署全栈项目。springboot后端,react前端
前端·spring boot·docker
像风一样自由20202 小时前
HTML与JavaScript:构建动态交互式Web页面的基石
前端·javascript·html
aiprtem3 小时前
基于Flutter的web登录设计
前端·flutter
浪裡遊3 小时前
React Hooks全面解析:从基础到高级的实用指南
开发语言·前端·javascript·react.js·node.js·ecmascript·php
why技术3 小时前
Stack Overflow,轰然倒下!
前端·人工智能·后端
GISer_Jing3 小时前
0704-0706上海,又聚上了
前端·新浪微博
止观止4 小时前
深入探索 pnpm:高效磁盘利用与灵活的包管理解决方案
前端·pnpm·前端工程化·包管理器
whale fall4 小时前
npm install安装的node_modules是什么
前端·npm·node.js
烛阴4 小时前
简单入门Python装饰器
前端·python
袁煦丞5 小时前
数据库设计神器DrawDB:cpolar内网穿透实验室第595个成功挑战
前端·程序员·远程工作