Run BlockUI on page load?
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>
精彩评论