Prevent page scrolling after mask layer

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'); //Make the page unscrollable
   $(".searchbox").show();
 })
 $(".yg-close").click(function(){
   $('html,body ').removeClass('ovfHiden'); //Make the web page scrollable
   $(".searchbox").hide();
 })

Two: The page is normally static
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);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326465854&siteId=291194637