confirm消息對話框,表示確認的意思,彈出的對話框包含一個確定和取消按鈕
語法:
confirm(str);
str:表示在對話框中顯示的內容
返回值爲Boolean型
當用戶點擊了確認按鈕時,那麼返回true
當用戶點擊了取消按鈕時,那麼返回false
例:<script type="text/javascript">
function rec(){
var mymessage=comfirm();
if(mymessage==true){
document.write("很不錯嘛!");
}else{
document.write("繼續裝個逼吧!");
}
}
</script>
<body>
<input name="button" type="button" onClick="rec()" value="點擊我吧!">
</body>