how do I center javascript css popup div, no matter what the screen resolution?

后端 未结 7 1320
一生所求
一生所求 2021-02-07 08:14

I have the following code that opens a new popup window while disabling the background, the problem is that I have to position this so that it\'s 100px from the top (already got

7条回答
  •  再見小時候
    2021-02-07 08:55

    A quick Google search found this;

    function PopupCenter(pageURL, title,w,h) {
      var left = (screen.width/2)-(w/2);
      var top = (screen.height/2)-(h/2);
      var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
    
    } 
    

提交回复
热议问题