Prevent Background Scrolling When Displaying Popup

Joe picture Joe · Feb 4, 2010 · Viewed 51.5k times · Source

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.

Answer

sudhAnsu63 picture sudhAnsu63 · Aug 17, 2012

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";