'document.writeln(something(params))'什么也没做

时间:2012-09-07 03:16:07

标签: javascript

我是JavaScript的新手,正在学习教科书。我在下面写了代码,并且正确显示了警告模态窗口,但document.writeln(triangle(8,5))什么也没做。为什么呢?

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Area of Triangle</title>
</head>
<body>
    <h1>Area of Triangle</h1>
    <pre>
        <script type="text/javascript" charset="utf-8">
            <!--

            var triangle;

            triangle = function(base, height) {
              return base * height / 2;
            };

            alert(triangle(8, 5));

            documnt.writeln(triangle(8, 5));

            -->
        </script>
    </pre>
</body>
</html>

谢谢你的善意。

1 个答案:

答案 0 :(得分:2)

您错误documentdocumnt。尝试:

document.writeln(triangle(8, 5));