Posted on 2013-06-19 21:35
张力 阅读(319)
评论(0) 编辑 收藏
效果图:
代码
/**
* 通用等待处理
* @author 张力
* 用法 loading.start();则显示 loading.close();则关闭
*/
var loading={
'id':'loading',
'name':'loading',
'init':function(){
return parent.parent.parent.parent.parent.parent.document;
},
'start':function(){
var pdocument = this.init();
var bgObj=pdocument.createElement("div");
bgObj.setAttribute('id','bgDiv');
bgObj.style.position="absolute";
bgObj.style.background="#FFFFFF";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=1,opacity=20,finishOpacity=75";
bgObj.style.opacity="0.5";
bgObj.style.top="0";
bgObj.style.left="0";
bgObj.style.width="100%";
bgObj.style.height="100%";
bgObj.style.zIndex = "1000";
pdocument.body.appendChild(bgObj);
var loaddiv=document.createElement("div");
loaddiv.setAttribute('id','loaddiv');
loaddiv.setAttribute('align','center');
loaddiv.style.top="50%";
loaddiv.style.left="50%";
loaddiv.style.position="absolute";
loaddiv.style.zIndex = "1001";
loaddiv.innerHTML="<img src='images/loading_img.gif' ></br>正在处理,请稍候....";
pdocument.body.appendChild(loaddiv);
},
'close':function (){
var pdocument = this.init();
pdocument.body.removeChild(pdocument.getElementById("bgDiv"));
pdocument.body.removeChild(pdocument.getElementById("loaddiv"));
}
};