I am trying to open new window from a lightning component using window.open

I want to center this new window in the middle of the screen.

for this I am using this code :

var myWidth= 600;
        var myHeight=window.innerHeight;
        var left = (screen.width - myWidth )/ 2;
        var top = (screen.height - myHeight) ;


This work well when I open the window from my laptop screen but not at all when I open it from an other monitor.

what can I do to make sure this new window will always appear in the middle of the screen , no matter the size of the screen?


Check this post out, should have the answer you are looking for:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.