求教大神 appendChild错哪了

求教大神appendChild哪里错了啊HTML codehtmlheadscriptwindow.onloadfunction(){var bdocument.g

求教大神 appendChild哪里错了啊

HTML code
<html>    <head>    <script>    window.onload=function(){    var b=document.getElementsByTagName("body");        var d = document.createElement("div");    b.appendChild(d)    }    </script>    </head>    <body >        </body><html>


[解决办法]
getElementsByTagName也得这样使用
var b=document.getElementsByTagName("body")[0];