533
Views
9
Comments
Disable body scroll when opening popup
Question

Hi!

I'm having a hard time hiding my body scroll.

The situation is: I implemented a component to make the popup fullscreen. When it is in fullscreen mode, the Y scroll of the body is showing. I would like only the popup scroll to appear.

If you place (overflow-y: hidden;) on the webscreen, the scroll will always hide. But I want to hide it only when the popup is running (open on the screen). When closing the popup, the page scroll appears again.

2020-01-08 08-43-00
Rahul Kumar

Hi Danilo, 

Which component you have used to make pop up full screen ? Have you used LayoutPopUp for Pop Up page ?


Thanks and Regards,

Rahul

UserImage.jpg
Danilo Vilarinho Barbosa

Hello Rahul!

Yes, I am using the popup layout.

2026-01-26 10-25-31
Lennart Kraak
Champion

Hey Danilo,

Two things:

1. Isn't it easier to use a modal popup, such that people cannot access the parent?
2. Have you tried disabling the scrollbar from the popup via window.parent?

Regards,
Lennart

UserImage.jpg
Danilo Vilarinho Barbosa

Yes. As it is already an old project. I want to continue working with him, as it is only this modification that I need to make.

When I click on the button I use JQuery to make it Fullscren. Follow the code.

$(document).ready(function(){
    
  $('#"+btnExpand.Id+"').click(function(){
 
    $('.os-internal-Popup', window.parent.document).attr('style', 'top: 0px!important');
    $('.os-internal-Popup', window.parent.document).css('left','0px');
    $('.os-internal-Popup', window.parent.document).css('z-index','5000');
    $('.os-internal-Popup', window.parent.document).width('100%');
    $('.os-internal-Popup', window.parent.document).height('100%');
    
  });


UserImage.jpg
Danilo Vilarinho Barbosa

Danilo Vilarinho Barbosa wrote:

Yes. As it is already an old project. I want to continue working with him, as it is only this modification that I need to make.

When I click on the button I use JQuery to make it Fullscren. Follow the code.

$(document).ready(function(){
    
  $('#"+btnExpand.Id+"').click(function(){
 
    $('.os-internal-Popup', window.parent.document).attr('style', 'top: 0px!important');
    $('.os-internal-Popup', window.parent.document).css('left','0px');
    $('.os-internal-Popup', window.parent.document).css('z-index','5000');
    $('.os-internal-Popup', window.parent.document).width('100%');
    $('.os-internal-Popup', window.parent.document).height('100%');
    
  });


That way I can assign new CSS properties to my popup. But I can't attribute it to the body, which would be the father.


UserImage.jpg
Danilo Vilarinho Barbosa

Danilo Vilarinho Barbosa wrote:

Danilo Vilarinho Barbosa wrote:

Yes. As it is already an old project. I want to continue working with him, as it is only this modification that I need to make.

When I click on the button I use JQuery to make it Fullscren. Follow the code.

$(document).ready(function(){
    
  $('#"+btnExpand.Id+"').click(function(){
 
    $('.os-internal-Popup', window.parent.document).attr('style', 'top: 0px!important');
    $('.os-internal-Popup', window.parent.document).css('left','0px');
    $('.os-internal-Popup', window.parent.document).css('z-index','5000');
    $('.os-internal-Popup', window.parent.document).width('100%');
    $('.os-internal-Popup', window.parent.document).height('100%');
    
  });


That way I can assign new CSS properties to my popup. But I can't attribute it to the body, which would be the father.


If you put this code snippet inside my onclick, it will hide the Y scroll from my popup. But not my primary webscreen.


$('body').css('overflow-y','hidden');


UserImage.jpg
Mahesh Nannaware

As I'm also facing this issue on ios phone. once pop up open then background page also scrolling with Pop up.
Please do needful on this

2023-03-09 07-10-59
Vipasha Sharma

Hi Danilo,

You can use conditional CSS to hide the scroll, please follow the below steps to do so:

Step 1: Use a flag (boolean variable, default value as false) inside the screen action from which you open the popup and make it true only when you click to open popup.

Step 2: Use style extended property of the screen and with the help of your flag variable hide the scroll of main screen as shown in below snapshot. (I enclose all the elements of main screen inside the container and use container's style property)

Step 3: Make the variable as false when you close the popup.

Hope this helps you

Regards,

Vipasha

UserImage.jpg
Mahesh Nannaware

Thanks Vipasha. It is not working for iphone 5s and iphone 6 As I have tested on iphone 11 that issue is not coming on device. 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.