开发者

jQuery BlockUI Plugin method blockUI how to display just image without any background

Here is on the sample page http://jquery.malsup.com/block/ is an example of an overlay message with an image:

$.blockUI({ message: '<h1><img src="busy.gif" /> Just a moment...</h1>' });

But I want to display just an image, so I took out the h1 tag:

$.blockUI({ message: '<img src="busy.gif" />' });

But there is still a background color under my image. How can I remove it?

According with source code of jQuery BlockUI Plugin (v2) it is wrapping the message in an h2 tag

if (title) $m.append('<h1>'+title+'</h1>');
if (message) $m.append('<h2>'+message+'</h2>');

so it looks like there is no way without modification of the source code to pass just an image tag.

I might modify the library source code to introduce a new param like image with a condition:

if (image) $m.append(开发者_如何学运维image);

and than I could declare my image like this:

$.blockUI({ image: '<img src="busy.gif" />' });

Any more ideas?


By default you got that:

    // styles for the message when blocking; if you wish to disable
    // these and use an external stylesheet then do this in your code:
    // $.blockUI.defaults.css = {};
    css: {
        padding:    0,
        margin:     0,
        width:      '30%',
        top:        '40%',
        left:       '35%',
        textAlign:  'center',
        color:      '#000',
        border:     '3px solid #aaa',
        backgroundColor:'#fff',
        cursor:     'wait'
    },

So if you don't want any of these just do that in your code:

$.blockUI.defaults.css = {};

Or if you want to exclude background and border just go with that insteard:

$.blockUI.defaults.css = { 
            padding: 0,
            margin: 0,
            width: '30%',
            top: '40%',
            left: '35%',
            textAlign: 'center',
            cursor: 'wait'
        };

Basically using that external stylesheet you may specify any css style you want.


This one works perfectly

$.blockUI({ message: '<img src="your.gif" />' ,
css: { width: '4%', border:'0px solid #FFFFFF',cursor:'wait',backgroundColor:'#FFFFFF'},
  overlayCSS:  { backgroundColor: '#FFFFFF',opacity:0.0,cursor:'wait'} 
}); 


You can also override some css params when calling blockUI(). Like this:

  $.blockUI({
    'message':$('#div-'+$(this).attr('id')),
    'css':{width:539,height:539,top:'80px',left:($(window).width()-539)/2+'px',border:0}
  });


You can override the css for overlay

$.blockUI.defaults.overlayCSS.opacity = 0;

More here: http://jquery.malsup.com/block/#options


just hit this url : https://sites.google.com/site/atgcorner/Downhome/javascript/jqueryblockuipopupwithimage-1

then with a litle implementation in my code..

 

var spinnerImg = new Image();


spinnerImg.src = "${spinnerImage}";

    function loadpage() { 
        $.ajax({ url: 'wait.jsp', cache: false }); 
    } 

    function testload(){
         var msg = "";
         $.blockUI({ 
            message: $(' Wait a moment..'),             
             css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#fff', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .5,            
            color: '#000' 
        } }); 
         loadpage();    
         setTimeout($.unblockUI, 6000);

    }

IT Works fine (i'm currently using FF 31.0 & Chrome 36.0)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜