- 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];