Center align the pop-up - Javascript

Hi,

I am using

window.open

method to open a new window. Can you please let me know how to make it center becuase right now it is showing left side of the screen ? I want vertically as will as horizontally center alignment.

Thanks
milani_lucieAsked:
Who is Participating?
 
tdlewisConnect With a Mentor Commented:
First decide the size of the window, then the following will work:
w = 400 // or desired width
h = 600 // or desired height
t = Math.floor((screen.height - h) / 2)
l = Math.floor((screen.width - w) / 2)
window.open(url,name,"top="+t+",left="+l+",height="+h+",width="+w)

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.