// 定义页面加载等待效果 function Loading() { this.cont = $(window); // 容器 this.height = this.cont.height(); // 容器的高度 this.width = this.cont.width(); // 容器的宽度 } Loading.prototype.showLoading = function(container) { this.hideLoading(container); var zIndex = '999997'; var isBody = false; if(container != undefined) { this.cont = container; // 重新定义容器 zIndex = '999'; }else { this.cont = $('body'); isBody = true; } this.height = this.cont.height(); // 容器的高度 this.width = this.cont.width(); // 容器的宽度 this.cont.css('position', 'relative'); var imgDiv = $('
'); // 容器是body if(isBody) { imgDiv.addClass('loading-fixed'); } var img = $('
');
imgDiv.append(img);
var mask = $('');
mask.css({
'position': 'absolute',
'top': 0,
'left': 0,
'z-index': zIndex,
'width': '100%',
'height': this.height+'px',
'background-color': '#3A3939',
'filter':'alpha(opacity=210)', /*IE滤镜,透明度50%*/
'-moz-opacity':0.1, /*Firefox私有,透明度50%*/
'opacity':0.1 /*其他,透明度50%*/
});
this.cont.append(mask);
this.cont.append(imgDiv);
};
Loading.prototype.hideLoading = function(container) {
//console.info("8888888888888888");
if(container != undefined) {
this.cont = container; // 重新定义容器
this.height = this.cont.height(); // 容器的高度
this.width = this.cont.width(); // 容器的宽度
}else {
this.cont = $('body');
}
this.cont.children('.loading').remove();
this.cont.children('.loading-mask').remove();
};
var loading = new Loading();