Home  >  Article  >  Web Front-end  >  How to prevent page scrolling behind mask layer

How to prevent page scrolling behind mask layer

黄舟
黄舟Original
2017-10-24 10:36:012281browse


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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn