[snippet] pop layer

tipLoad:function(tip,disableScroll){
        var maskDiv=$("<div></div>"),tipDiv;
        if(!$(tip).length)tipDiv=$("<div class='tipDiv'>"+tip+"</div>");
        else {
            tipDiv=$(tip);
            tipDiv.css({"marginLeft":-tipDiv.width()/2,"marginTop":-tipDiv.height()/2,"zIndex":"1001","position":"absolute","top":"50%","left":"50%"}).show();}
            maskDiv.css({"background":"rgba(0,0,0,0.5)","zIndex":"1000","position":"absolute","top":"0","left":"0"})
                .height($(document).height())
                .width($(document).width())
                .click(function(){$(this).fadeOut("fast",function(){$(this).remove();});tipDiv.hide("fast");$(window).unmousewheel();});
        if(disableScroll){
            jqMousewheel = document.createElement('script');
            jqMousewheel.src="jquery.mousewheel.js";
            jqMousewheel.type = 'text/javascript';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(jqMousewheel, s);
            jqMousewheel.onload = jqMousewheel.onreadystatechange = function(){$(window).mousewheel(function (){return false;})}; 
        }
        $("body").append(maskDiv,tipDiv);    
        }


css

自定义的层:

height:100px; width:100px; background:#096; display:none;

调用方式:

showLoad.tipLoad('#e',1)

第二个参数为是否禁用滚轮,需将jquery.mousewheel.js置于目录。

默认提示层css

.tipDiv{
    position:absolute;
    top:50%;
    left:50%;
    padding-top:40px;
    height:30px;
    width:150px;
    margin:-35px 0 0 -75px;
    background:url(load.gif) center top no-repeat;
    text-align:center;
    font:14px Verdana, Geneva, sans-serif;
    z-index:1000;
    color:#eee;}

 

posted @ 2014-05-04 16:53  ipup  阅读(291)  评论(0编辑  收藏  举报