开发者

Run BlockUI on page load?

开发者 https://www.devze.com 2023-04-04 13:49 出处:网络
How can I run the BlockUI plugin (http://www.malsup.com/jquery/block/#demos) when the page loads? I modified it so that when you click the body tag it runs the plugin, but I want that to happen when t

How can I run the BlockUI plugin (http://www.malsup.com/jquery/block/#demos) when the page loads? I modified it so that when you click the body tag it runs the plugin, but I want that to happen when the page loads...

<script type="text/javascript" language="javascript">
$(document).ready(function() { 
    $('body').click(function() {
        $.blockUI({ 开发者_Go百科css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#000', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .5, 
            color: '#fff' 
        } }); 

        setTimeout($.unblockUI, 2000); 
    }); 
}); 
</script>


Just take it out of the click method.

$(document).ready(function() {
    blockUI({ parameters });
    setTimeout...
    $('body').click...
}


take it out from that click event (or copy-paste (or use function - the best one))

<script type="text/javascript" language="javascript">
$(document).ready(function() { 
    $.blockUI({ css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#000', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .5, 
            color: '#fff' 
    } }); 
    setTimeout($.unblockUI, 2000);
    $('body').click(function() {
        $.blockUI({ css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#000', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .5, 
            color: '#fff' 
        } });  
        setTimeout($.unblockUI, 2000);
    }); 
}); 
</script>
0

精彩评论

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