确认功能不起作用 [英] confirm function is not working

查看:95
本文介绍了确认功能不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

*<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>*

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

I want to know what's the problem. It is not working but it is the same as in http://www.w3schools.com/js/js_popup.asp

推荐答案

  1. 您正在递归调用 confirm(),它处于无限循环中
  2. 文档的开头和结尾处都有一个 *
  3. 正如肯尼贝克指出的那样,您正在覆盖 window.confirm
  4. 您在< body>
  5. 中有一个悬挂端</div>
  1. You are recursively calling confirm() and it's in an infinite loop
  2. You have a * at the beginning and end of the document
  3. As kennebec pointed out, you're overwriting window.confirm
  4. You have a hanging end </div> in the <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>

这篇关于确认功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆