js三种消息框消息框

警告框alert

<html>  
<head>  
<script type="text/javascript">  
function disp_alert()  
{  
alert("这是" + '\n' + "警告框。")  
}  
</script>  
</head>  
<body>  
  
<input type="button" onclick="disp_alert()" value="显示警告框" />  
  
</body>  
</html> 

确认框confirm

<html>  
<head>  
<script type="text/javascript">  
function show_confirm()  
{  
var r=confirm("单击一个按钮!");  
if (r==true)  
  {  
  alert("你点了确定!");  
  }  
else  
  {  
  alert("你点了取消!");  
  }  
}  
</script>  
</head>  
<body>  
  
<input type="button" onclick="show_confirm()" value="Show a confirm box" />  
  
</body>  
</html> 

 提示框

<html>  
<head>  
<script type="text/javascript">  
function disp_prompt()  
  {  
  var name=prompt("请输入您的名字","Tomy")  
  if (name!=null && name!="")  
    {  
    document.write("你好!" + name + " 今天天气不错哦~")  
    }  
  }  
</script>  
</head>  
<body>  
  
<input type="button" onclick="disp_prompt()" value="显示提示框" />  
  
</body>  
</html>

 

posted @ 2015-04-29 14:50  培杰  阅读(190)  评论(0编辑  收藏  举报