<body>
<script type="text/javascript">
var main = document.body;
//创建链接
function createa(url,text)
{
var x=document.createElement("a");
x.setAttribute("href",url);
x.innerHTML=text;
x.style.color="green";
main.appendChild(x);
}
// 调用函数创建链接
createa(" http://www.imooc.com","慕课网")
</script>
</body>
其实就是获取文档中的body标签
其实意思就是document.getElementsByTagName("body")[0]