Js_消息框

来源:岁月联盟 编辑:exp 时间:2012-03-30

警告框

[javascript] <html> 
<head> 
<script type="text/javascript"> 
function disp_alert() 

alert("这是" + '/n' + "警告框。") 

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

<input type="button" onclick="disp_alert()" value="显示警告框" />

</body>
</html>

确认框

[javascript] <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 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>提示框

[javascript]<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> 

 

摘自  Click Here