请问代码那有问题?

来源:1-2 编程练习

程序猿擎天柱

2015-06-18 17:49

<!DOCTYPE HTML>

<html>

<head>

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

<title>系好安全带,准备启航</title>

<!--引入外部文件的方式-->


<script type="text/javascript">

    function go()

    {

        var zou=confirm("点击");

        if (zou==true)

        {

            document.write("准备好,起航吧");

        }

        else{

            document.write("ssssswandanle ");

        }

        

        

        }



</script>

</head>

<body>


    <input type="button" onclick="go" value="点击">

    </input>


</body>

</html>


写回答 关注

2回答

  • 幕布斯9266291
    2022-04-11 18:44:31

    可能是线路的问题,或者是你浏览器的设置。

    bqgnvftukyj

  • Perona
    2015-06-18 18:25:24
    document.write("准备好,起航吧");
    document.write("ssssswandanle ");

    这2行最后的分号改为英文的分号

     document.write("准备好,起航吧");
     document.write("ssssswandanle ");
    <input type="button" onclick="go" value="点击">

    这里调用函数缺了()

    <input type="button" onclick="go()" value="点击">

    完整代码

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>系好安全带,准备启航</title>
    <!--引入外部文件的方式-->
    
    
    <script type="text/javascript">
        function go()
        {
            var zou=confirm("点击");
            if (zou==true)
            {
                document.write("准备好,起航吧");
            }
            else{
                document.write("ssssswandanle ");
            }
           
         }
    
    
    
    </script>
    </head>
    <body>
    
    
        <input type="button" onclick="go()" value="点击">
        </input>
    
    
    </body>
    </html>


JavaScript进阶篇

本课程从如何插入JS代码开始,带您进入网页动态交互世界

467373 学习 · 21877 问题

查看课程

相似问题