实现功能:需要用户等待时弹出js下alert的效果,避免用户再点击其它操作。只是alert窗口换成特定说明文字
操作示例: $.loadingbox.show(); $.loadingbox.close();
/*!
* jQuery loadingbox
* Copyright 2011, Harden63
* Date: 2011-11-16 20:17:30
*/
(function($){
$.loadingbox={
show:function(){
if($('#divBlack_6317').length > 0)
return;
var $divBlack = $("
");
var $divWhite = $("
");
var width = $(document.body).width();
var height = $(document.body).height();
if(width < $(document).width())
width = $(document).width();
if(height < $(document).height())
height = $(document).height();
$divBlack.css({
'position': 'absolute',
'top': '0%',
'left': '0%',
'width': width,
'height': height,
'background-color': 'black',
'z-index':'6316',
'-moz-opacity': '0.4',
'opacity':'.40',
'filter': 'alpha(opacity=40)'
});
$divWhite.css({
'position': 'absolute',
'top': '40%',
'left': '40%',
'width': '200px',
'height': '50px',
'padding': '16px',
'border': '8px solid orange',
'background-color': 'white',
'z-index':'6317',
'overflow': 'hidden',
'color':'blue',
'font-weight':'bold',
'padding':'0px'
});
$('body').append($divBlack);
$('body').append($divWhite);
var $barDiv = $("
Please wait .....
");
var $bar = $("");
$barDiv.append($bar);
$divWhite.append($barDiv);
setInterval(drawLoading,700);
},
close:function(){
if($('#divBlack_6317').length <= 0)
return;
$('#divBlack_6317').remove();
$('#divWhite_6317').remove();
}
};
function drawLoading(){
$('#bar').css('width',$('#bar').width() + 50);
if($('#bar').width() > 400){
$('#bar').css('width','0%');
}
}
})(jQuery);