One: The page will be initialized to the top and then static
css code:
.ovfHiden{overflow: hidden;height: 100%;}
jquery:
$(".header_right").click(function(){$('html,body').addClass('ovfHiden'); //使网页不可滚动 $(".searchbox").show(); }) $(".yg-close").click(function(){ $('html,body').removeClass('ovfHiden'); //使网页恢复可滚 $(".searchbox").hide(); })
Two: Page Normal stillness
1. When opening a new page, you need to disable the mouse wheel and page sliding;
Just add this js code when calling the display layer:
document.documentElement.style.overflow = "hidden";
Don’t forget to add this sentence when closing the layer:
document.documentElement.style.overflow = "scroll";
2. Set the original position of the scroll wheel
var top_temp = $(document).scrollTop()||document.documentElement.scrollTop || document.body.scrollTop; window.parent.scrollTo(0,top_value);
The above is the detailed content of How to prevent page scrolling behind mask layer. For more information, please follow other related articles on the PHP Chinese website!