title: JS - Div on center screen
body: <p>I have this problem I have a hidden div in css. when i click a button the div is shown. But I would like it to be shown in the center of the screen, and in the position I am in. Let me explain, if I am in the middle of the page I would like to show it in the middle of the page and in the center (vertical and horizontal), if I am at the end of the page, I want to show it at the end of the page in the center.
  I need to do this in js.</p>
  <p>With this function I can do something, but the div is shown in the center of the page and I am moved to the center, while I would not want to move from the position I am in, and open the div in the center of the screen</p>
  <pre><code>    function setToCenterOfParent(element, parent, ignoreWidth, ignoreHeight){
          parentWidth = $(parent).width();
          parentHeight = $(parent).height();  
          elementWidth = $(element).width();
          elementHeight = $(element).height();
          if(!ignoreWidth)
              $(element).css('left', parentWidth/2 - elementWidth/2);
          if(!ignoreHeight)
              $(element).css('top', parentHeight/2 - elementHeight/2);
      }
  </code></pre>
  <p>Can you help me?
  Thank you</p>