Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Background Scrolling When Displaying Popup

Tags:

I have a form that is displayed in a popup. After loading, the background is grayed out, but the user can still scroll the background content up and down.

How do I prevent the background from scrolling?

Example here

the 'email this quote' link to the right of the pdf screenshot.

like image 438
Joe Avatar asked Feb 04 '10 17:02

Joe


People also ask

How do I stop the background when modal windows pop up?

The key idea is to have pointer-events: none; for the body when modal is open. But the specific elements you want to be interacted with should have e.g. pointer-events: auto; . In the example you can click both buttons when dialog is hidden, but only Toggle Dialog button when dialog is shown.

What prevents the body from scrolling when overlay is on?

Approach: To prevent body scrolling but allow overlay scrolling we have to switch the overflow to be hidden when the overlay is being shown. And while the whole page's overflow is hidden or the scroll is disabled the overflow in the y-axis of the overlay is enabled and the overflow can be scrolled.

How do I remove the scrollbar from a pop up window?

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 3: Make the variable as false when you close the popup.


1 Answers

To hide the scrollbar of the body when opening the popup

document.body.style.overflow = "hidden"; 

and to revert back when closing the popup

document.body.style.overflow = "visible"; 
like image 86
sudhAnsu63 Avatar answered Oct 17 '22 07:10

sudhAnsu63