[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

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
0
milani_lucie
Asked:
milani_lucie
1 Solution
 
tdlewisCommented:
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now