畫面不可滑動(顯示目前畫面),如有ScrollBar ,則鎖住使用
測試可用版本: IE8+,FIREFOX,CHROME
測試不可用版本:IE7
CSS設定
html.noscroll {
position: fixed;
overflow-y: scroll;
width: 100%;
}
html.fixWindow {
position: fixed;
width: 100%;
}
JS設定
鎖住畫面
if ($(document).height() > $(window).height()) {
$("html").addClass("noscroll");
}else{
$("html").addClass("fixWindow");
}
解開畫面
if ($(document).height() > $(window).height()) {
$("html").removeClass("noscroll");
}else{
$("html").removeClass("fixWindow");
}
參考:
http://stackoverflow.com/questions/8701754/just-disable-scroll-not-hide-it
文章標籤
全站熱搜