Ok, using overflow:hidden;
the page don't scroll and don't shows scrollbars.
What i would like to achieve is to disable body from scrolling but showing scrollbars, like to make scrollbars static/disabled without having to hide them.
ユーザーがモーダル内をスクロールできるようにする必要がありますが、同時にモーダルのスクロール中にページをスクロールしないでください。
ボディスクロールバーを非表示にせずに可能ですか?
どうもありがとう、私は困っていて、まともなコードを取得できません:/ 私のjsは次のようになります(ただし、これによりボディスクロールバーが非表示になり、とにかく表示したい:/)
function blockScrolling(){
var scrollPosition = [
self.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
];
var html = jQuery('html'); // it would make more sense to apply this to body, but IE7 won't have that
html.data('scroll-position', scrollPosition);
html.data('previous-overflow', html.css('overflow'));
html.css('overflow', 'hidden');
window.scrollTo(scrollPosition[0], scrollPosition[1]);
}
function unblockScrolling(){
// un-lock scroll position
var html = jQuery('html');
var scrollPosition = html.data('scroll-position');
html.css('overflow', html.data('previous-overflow'));
window.scrollTo(scrollPosition[0], scrollPosition[1])
}
function modals(){
$('.modal').hide();
$('.modal').on('show shown',function(){
blockScrolling();
});
$('.modal').on('hide hidden',function(){
unblockScrolling();
});
}