0

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) ;

window.open('https://salesforce.stackexchange.com/','_blank','height='+myHeight+',width='+myWidth+',left='+left);

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?

0

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

https://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen

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.