JavaScript Popup Boxes
来源:互联网 发布:网络通信协议 java 编辑:程序博客网 时间:2024/05/16 19:07
JavaScript has three kind of popup boxes: Alert box, Confirm box, and 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.
Syntax
alert("sometext");Example
<html><head>
<script type="text/javascript">
function show_alert()
{
alert("I am an alert box!");
}
</script>
</head>
<body>
<input type="button" onclick="show_alert()" value="Show alert box" />
</body>
</html>
Try it yourself »
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.
If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.
Syntax
confirm("sometext");Example
<html><head>
<script type="text/javascript">
function show_confirm()
{
var r=confirm("Press a button");
if (r==true)
{
alert("You pressed OK!");
}
else
{
alert("You pressed Cancel!");
}
}
</script>
</head>
<body>
<input type="button" onclick="show_confirm()" value="Show confirm box" />
</body>
</html>
Try it yourself »
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.
If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null.
Syntax
prompt("sometext","defaultvalue");Example
<html><head>
<script type="text/javascript">
function show_prompt()
{
var name=prompt("Please enter your name","Harry Potter");
if (name!=null && name!="")
{
document.write("Hello " + name + "! How are you today?");
}
}
</script>
</head>
<body>
<input type="button" onclick="show_prompt()" value="Show prompt box" />
</body>
</html>
Try it yourself »
- JavaScript Popup Boxes
- JS Popup Boxes
- div+javascript实现popup
- javaScript Popup.js
- Popup-Fenster mit JavaScript
- JavaScript About Popup
- javaScript Popup.js
- div+javascript实现popup
- JavaScript 模仿 MSN 消息 popup
- POPUP
- Popup
- popup
- popup
- popup
- popup
- popup
- popup
- popup
- The processing instruction target matching "[xX][mM][lL]" is not allowed.
- NET 2.0 - WinForm Control - DataGridView 编程36计(一)
- 连接跟踪与nat转换
- 情商管理
- 深入分析 Java 中的中文编码问题
- JavaScript Popup Boxes
- js 实现 设置首页,添加收藏功能,兼容IE/ff
- DHD刷机
- eclipse无法开启问题
- 用SetupDi* 启用/禁用网卡
- 安装多系统
- Java与设计模式学习(一)--工厂方法模式FACTORY METHOD
- android应用开发之intent详解
- Modernizr——为HTML5和CSS3而生!