js消息框類別:警告框、確認框、提示框
警告框:alert("文本");
確認框:confirm("文本");
提示框:prompt("文本","默認值");
一:confirm使用范例
<script type="text/javascript">
function test(){
var res = confirm("請選擇");
if(res == true){
document.write("你點擊了確定");
}else{
document.write("你點擊了取消");
}
}
</script>
<input type="button" onclick="test()" value="confirm使用范例">
二:prompt使用范例:
<script type="text/javascript">
function test(){
var name = prompt("名稱","jack");
if(name!=null && name!=""){
document.write("hello" + name);
}
}
</script>
<input type="button" onclick="test()" value="prompt使用范例">
