1.判断浏览器的类型:
document.getElementById && document.getElementById()
//W3C DOM
document.all && document.all()
//MSIE 4 DOM
document.layers && document.layers[]
//NN 4 DOM
2.定义符号
function $( objectId) {
if ( document.all && document.all( objectId )) {
return document.all( objectId );
}
}
3.JS create Object
var oCar = new Object();
oCar.color = "red";
oCar.doors = 4;
oCar.showColor = function () {
alert( this.color); // PHP $this
}
oCar.showColor();
//javaScript对象默认成员属性都是public 的。这种方式我们称为工厂方式,我们创造了能创建并返回特定类型的对象的工厂。