问答详情
源自:2-2 JavaScript-警告(alert 消息对话框)

为什么alert窗口会出现2次?

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>alert</title>

  <script type="text/javascript">

  function rec(){

    var mychar="I love JavaScript";

alert(mychar);

  }

  </script>

</head>

<body>

    <input name="button" type="button" onClick="rec()" value="点击我,弹出对话框" />

</body>

</html>


提问者:qq_慕侠2446499 2019-04-26 23:01

个回答

  • qq_慕后端6367251
    2019-05-04 11:59:54

    <!DOCTYPE HTML>

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>alert</title>

      <script type="text/javascript">

      function rec(){

        var mychar="I love JavaScript";

    alert(mychar);

      }

      </script>

    </head>

    <body>

        <input name="button" type="button" onClick="rec()" value="点击我,弹出对话框" />

    </body>

    </html>


  • 慕斯6041710
    2019-04-27 15:12:38

    我试了下你的代码,只弹出了一次alert啊!