自己写的jQuery小插件——loadingbox

来源:互联网 发布:荣威erx5网络连接错误 编辑:程序博客网 时间:2024/06/02 13:30

实现功能:需要用户等待时弹出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);


原创粉丝点击