CCPry JS类库类库 代码代码
CCPry JS类库 代码,需要的朋友可以参下。
复制代码 代码如下:
function CCPry(){
//
// 判断浏览器类型
//
this.Browser ={
"isMozilla":(typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument !=
'undefined') && (typeof HTMLDocument!='undefined'),
"isIE":window.ActiveXObject ? true : false,
"isFirefox":navigator.userAgent.toLowerCase().indexOf("firefox")!=-1,
"isOpera":navigator.userAgent.toLowerCase().indexOf("opera")!=-1
};
//
//根据元素ID返回DOM对象
//
this.$Id=function(id){
return document.getElementById(id);
};
//
//根据元素ID返回DOM对象
//
this.Id=function(id){
var DomObjId=this.$Id(id);
if(!DomObjId){ throw new Error("No Object!");}
//返回或设置对象的innerHTML属性
this.Html=function(html){
if(!this.IsUndefined(DomObjId.innerHTML))
{
if(!this.IsNull(html)){
DomObjId.innerHTML=html;
}
else{ return DomObjId.innerHTML };
}
else{ throw new Error("Object does not support the property innerHTML!");};
};
//返回或设置对象的innerText属性
this.Text=function(text){
if(!this.IsUndefined(DomObjId.innerText))
{
if(!this.IsNull(text)){
DomObjId.innerText=text;
}
else{ return DomObjId.innerText };
}
else{ throw new Error("Object does not support the property innerText!");};
};
//返回或设置对象的value属性
this.Val=function(val){
if(!this.IsUndefined(DomObjId.value))
{
if(!this.IsNull(val)){
DomObjId.value=val;
}
else{ return DomObjId.value };
}
else{ throw new Error("Object does not support the property value!");};
}
return this;
};
//