2

I'm trying to disable scroll for a popup to appear. I'm using the following code:

height: 100%;
overflow: hidden;

When I apply these styles, I go to the top of my page. I want to prevent scroll, but also stay in the same position. This is for a Sign Up popup. So, I want the users to be able to see what made them want to Sign Up in the background. Any ideas?

Cøde Play
  • 167
  • 10

2 Answers2

0

You should use overflow: hidden; on body, and simpliest way to make popup 100% on height and width is to give popup wrapper position: fixed; left: 0; top: 0; right: 0; bottom: 0; z-index: 1000 Z index is for you to choose (so popup won't be overlaped by other container).

0

Although the scroll is hidden, you can use window.scrollTo() function to set the scroll wherever you need, something like

window.scrollTo(0, 0);

You can get the scroll position before opening the sing in dialogue this way.

window.scrollTop

window.scrollLeft

That could be the x and y you're looking for

 

Jorge
  • 1,136
  • 9
  • 15
  • How do you get the x and y coordinates? That way, I could create two variables `x` and `y` before the popup, then do `window.scrollTo(x, y)` – Cøde Play Apr 16 '16 at 15:59