<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>
<body>
<script type="text/javascript">
var main = document.body;
//创建链接
function createa(url,text)
{
var a=createElement("a");
a.href=url;
a.innerHTML=text;
main.appendChild("a");
}
// 调用函数创建链接
main.createa("http://www.baidu.com","百度");
</script>
</body>
</html>
var a=createElement("a")这行代码应该写成document.createElement("a");
main.appendChild(createa("http://www.baidu.com","百度"));才是正确的调用方法
function中需要返回return a;
将function中的main......去掉