JavaScript提供了三个很不错的对话框函数,使用这三个函数可以很方便的显示一个对话框;
一、alert();
<script type="text/javascript">
alert("你好,"+'\n'+"这是第二行内容");
</script>
二、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="单击来看看有什么" />
三、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 ="显示窗口来看看" />