Pop-Up Window, Center Screen

前端 未结 3 783
感情败类
感情败类 2021-02-05 16:23

I\'m using the following code to open a pop-up window in a Google Chrome extension, my one question is, how do I get the pop-up window to open in the centre of the users screen?

3条回答
  •  长发绾君心
    2021-02-05 17:05

    As an addendum to this answer, if you want to retrieve popup dimensions from localstorage--which are saved as strings--this will convert the variables to the necessary integers for the pop-up to work.

     var w =  parseInt(localStorage.getItem('key'));
     var h =  parseInt(localStorage.getItem('key'));
    

提交回复
热议问题