简体   繁体   English

在弹出页面加载时使用jquery或javascript隐藏背景网页垂直滚动条

[英]hide background webpage vertical scrollbar using jquery or javascript while load of popup page

By clicking <a>click me</a> tag, the popup windows will get load. 通过单击<a>click me</a>标签,将弹出窗口加载。 At the time background page vertical scroll bar is on visible state. 在背景页面垂直滚动条处于可见状态时。 How can i hide while my popup load and visible when it close. 弹出窗口加载时如何隐藏,关闭时可见。

I used below script only: 我只使用以下脚本:

if($("#myModal").is(':visible')){  // here 'myModal' is div of popup.
   $("html").css("overflow", "hidden");  // here 'html' is a background page
   }
   else
  {
   $("html").css("overflow", "visible");
  }

Hide state is working properly, but visible state not working when i close the popup window. 隐藏状态正常工作,但是当我关闭弹出窗口时可见状态不工作。

Please give me a correct solutions. 请给我一个正确的解决方案。

Depends on the way you implement your modal... If for example you are using the jQuery UI Dialog Widget you would do something like: 取决于实现模态的方式...例如,如果您使用的是jQuery UI Dialog Widget,您将执行以下操作:

$("a.mylink").dialog({
    open: function() {
        $("html").css("overflow", "hidden");
    },
    close: function() {
        $("html").css("overflow", "visible");
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM