JavaScript学习 常用的对话框函数

JavaScript提供了三个很不错的对话框函数,使用这三个函数可以很方便的显示一个对话框;

  一、alert();   

<script type="text/javascript">
alert("你好,"+'\n'+"这是第二行内容");
</script>

JavaScript学习  常用的对话框函数


  二、prompt();

     

<script type="text/javascript">
function disp_prompt(){
var name= prompt("Please enter you name","Aqua"); if(name!=null && name!=""){
document.write("Hello "+name+" !How are you today?");
}
} </script> <input type="button" onclick="disp_prompt()" value="单击来看看有什么" />

JavaScript学习  常用的对话框函数


   三、confirm()

  

<script type= "text/javascript">
function disp_confirm(){
var r = confirm("Press a Button");
if(r == true){
document.write("You Processed OK");
}else{
document.write("You Process Cancel");
}
}
</script>
<input type="button" onclick="disp_confirm()" value ="显示窗口来看看" />

JavaScript学习  常用的对话框函数

上一篇:Python开源异步并发框架


下一篇:php session memcache