HTML DOM confirm() ·½·¨

¶¨ÒåºÍÓ÷¨

confirm() ·½·¨ÓÃÓÚÏÔʾһ¸ö´øÓÐÖ¸¶¨ÏûÏ¢ºÍ OK ¼°È¡Ïû°´Å¥µÄ¶Ô»°¿ò¡£

Óï·¨

confirm(message)
²ÎÊý ÃèÊö
message ÒªÔÚ window Éϵ¯³öµÄ¶Ô»°¿òÖÐÏÔʾµÄ´¿Îı¾£¨¶ø·Ç HTML Îı¾£©

˵Ã÷

Èç¹ûÓû§µã»÷È·¶¨°´Å¥£¬Ôò confirm() ·µ»Ø true¡£Èç¹ûµã»÷È¡Ïû°´Å¥£¬Ôò confirm() ·µ»Ø false¡£

ÔÚÓû§µã»÷È·¶¨°´Å¥»òÈ¡Ïû°´Å¥°Ñ¶Ô»°¿ò¹Ø±Õ֮ǰ£¬Ëü½«×èÖ¹Óû§¶Ôä¯ÀÀÆ÷µÄËùÓÐÊäÈë¡£ÔÚµ÷Óà confirm() ʱ£¬½«ÔÝÍ£¶Ô JavaScript ´úÂëµÄÖ´ÐУ¬ÔÚÓû§×÷³öÏìӦ֮ǰ£¬²»»áÖ´ÐÐÏÂÒ»ÌõÓï¾ä¡£

ÌáʾºÍ×¢ÊÍ

Ìáʾ£º¶Ô»°¿ò°´Å¥µÄÎÄ×ÖÊDz»¿É¸Ä±äµÄ£¬Òò´ËÇëСÐĵرàдÎÊÌâ»òÏûÏ¢£¬Ê¹ËüÊʺÏÓÃÈ·ÈϺÍÈ¡ÏûÀ´»Ø´ð¡£

ʵÀý

<html>
<head>
<script type="text/javascript">
function disp_confirm()
  {
  var r=confirm("Press a button")
  if (r==true)
    {
    document.write("You pressed OK!")
    }
  else
    {
    document.write("You pressed Cancel!")
    }
  }
</script>
</head>
<body>

<input type="button" onclick="disp_confirm()"
value="Display a confirm box" />

</body>
</html>
VUE