var LILL ={};//创建全局
(function (wd) {
function $(id) {
return document.getElementById(id);
}
function alertNodeName(id) {
alert($(id).nodeName);
}
var name = "aaaa";
function showName()//函数
{
alert(name);
}
alert(wd);
wd['test'] = {};//创建对象
wd['test']['debuglog'] = alertNodeName;
wd['test']['name'] = name;
showName();
})(LILL);
之后引用写好的js文件,然后在html页面调用
<script>
window.onload=function () {
alert("test");
LILL['test']['debuglog']('AA');
}
</script>