var LILL ={};//創建全局(function (wd) { function $(id) { return document.getElementById(id); } function alertNodeName(id) { alert($(id).nodeName); } var n ...
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>