当前位置: 首页 > 网络学院 > 客户端脚本教程 > JavaScript > JS Popup Boxes

JavaScript
JS 介绍
JS 怎样使用
JS 在哪使用
JS 变量
JS If...Else
JS Switch
JS 操作符
JS Popup Boxes
JS 函数
JS For 循环
JS While 循环
JS Break 循环
JS For...In
JS 事件
JS Try...Catch
JS Throw
JS onerror
JS 特殊字符
JS Guidelines
JS 对象介绍

JavaScript 中的 JS Popup Boxes


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 1322 ::
收藏到网摘: n/a

In JavaScript we can create three kinds of popup boxes: Alert box, Confirm box, and Prompt box.
在JS里我们可以建立三种不同样子的popup boxes弹出框:警示框,确认框,信息框


Examples
例子

Alert box[警示框]

Alert box with line breaks[换行的警告框]

Confirm box[确认框]

Prompt box[信息框(可输入参数)]


Alert Box
警示框

An alert box is often used if you want to make sure information comes through to the user.
如果你想保证让用户得到信息就使用警示框

When an alert box pops up, the user will have to click "OK" to proceed.
当警示框弹出,用户必须按“OK”来继续

Syntax:
语法:

alert("sometext")

 


Confirm Box
确认框

A confirm box is often used if you want the user to verify or accept something.
确认框用来让用户核实或是接受一些信息。

When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.
当信息框弹出,用户必须按“OK”或者“Cancel”来继续

If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.
如果用户按"OK"就返回真,按"取消"就返回假

Syntax:
语法:

confirm("sometext")

 


Prompt Box
信息框

A prompt box is often used if you want the user to input a value before entering a page.
信息框用来让用户在进入页面前输入值。

When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value.
当信息框弹出,用户将在输入值后按“OK”或“Canel”来继续(下面的操作)

If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null.
按“OK”就会返回输入的值,按“取消”就会返回空值

Syntax:
语法:

prompt("sometext","defaultvalue")

评论 (1) 1 All

登陆 | 还没注册?