三种JavaScript 消息框
2015-09-24 09:43
399 查看
prompt 提示框
<html>
<head>
<script type="text/javascript">
function disp_prompt()
{
var name=prompt("请输入您的名字","Bill Gates")
if (name!=null && name!="")
{
document.write("你好!" + name + " 今天过得怎么样?")
}
}
</script>
</head>
<body>
<input type="button" onclick="disp_prompt()" value="显示提示框" />
</body>
</html>
confirm 确认框
<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 a confirm box" />
</body>
</html>
alert("我是警告框!!")
<html>
<head>
<script type="text/javascript">
function disp_alert()
{
alert 我是警告框!!
}
</script>
</head>
<body>
<input type="button" onclick="disp_alert()" value="显示警告框" />
</body>
</html>
<html>
<head>
<script type="text/javascript">
function disp_prompt()
{
var name=prompt("请输入您的名字","Bill Gates")
if (name!=null && name!="")
{
document.write("你好!" + name + " 今天过得怎么样?")
}
}
</script>
</head>
<body>
<input type="button" onclick="disp_prompt()" value="显示提示框" />
</body>
</html>
confirm 确认框
<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 a confirm box" />
</body>
</html>
alert("我是警告框!!")
<html>
<head>
<script type="text/javascript">
function disp_alert()
{
alert 我是警告框!!
}
</script>
</head>
<body>
<input type="button" onclick="disp_alert()" value="显示警告框" />
</body>
</html>
相关文章推荐
- JSF与Shale
- JSP 静态生成html的原理
- JS重新加载当前页面
- 深入浅出解析正则表达式-替换原则
- javascript之块级作用域的概念和闭包
- Echarts Jqplot嵌extjs4 windows 装配方法
- jsonp协议原理深度解析
- 易语言调用js实现md5加密
- io.js
- JavaScript的DOM编程--06--两个实验
- Json解析详解
- JSP实现添加功能和分页显示实例分析
- JSP使用MVC模式完成删除和修改功能实例详解
- JS+CSS实现简易的滑动门效果代码
- avalon js实现仿google plus图片多张拖动排序附源码下载
- js中不同的height, top的区别对比
- javascript同步服务器时间和同步倒计时小技巧
- JS实现滑动菜单效果代码(包括Tab,选项卡,横向等效果)
- JS基于面向对象实现的拖拽库实例
- JS模拟实现Select效果代码