From The Blog

jQuery Colorbox: Hide background page vertical scroll bar on open

28 October 2013, in JavascriptjQuery

To hide the scroll bar of the background page when the colorbox opens "like facebook for example"

 

/* make the page scroll dissapear when colorbox is open and retrieved back when colorbox is closed */
var screen_position;
$(document).bind('cbox_open', function() {
screen_position = $("body").scrollTop();
$('body').css({ overflow: 'hidden' });
$("body").scrollTop(0);
}).bind('cbox_closed', function() {
$('body').css({ overflow: 'auto' });
$("body").scrollTop(screen_position);
});



Post a Comment