确认功能不起作用

Sir*_*der 4 html javascript confirm function

*<html>
<head>
<title>practise</title>
<script type="text/javascript">
function confirm() {
    var r = confirm("Press the button");
    if (r == true) {
        alert("You are right");
    } else {
        alert("You are wrong");
    }
}

</script>
</head>

<body>
        <input type="button" name="submit" value="showtime" onclick="confirm()"/>
    </div>
</body>
</html>*
Run Code Online (Sandbox Code Playgroud)

我想知道问题是什么.它不起作用,但它与http://www.w3schools.com/js/js_popup.asp中的相同

vol*_*ron 7

  1. 你是递归调用的confirm(),它处于无限循环中
  2. *在文档的开头和结尾处有一个
  3. 正如肯尼贝克指出的那样,你正在覆盖 window.confirm
  4. 你有一个最终挂</div><body>

http://jsfiddle.net/cvyyL/

<html>
   <head>
      <title>practise</title>
      <script type="text/javascript">
         function show_confirm() {
            var r = confirm("Press the button");
            if (r == true) {
               alert("You are right");
            } else {
               alert("You are wrong");
            }
         }    
      </script>
   </head>
   <body>
      <input type="button" name="submit" value="showtime" onclick="show_confirm()"/>
   </body>
</html>
Run Code Online (Sandbox Code Playgroud)