TIMEX TIMEX - 1 year ago 60
HTML Question

After I launch a popup window, how do I move it to the center of the page?

popup = window.open(thelink,'Facebook Share','resizable=1,status=0,location=0,

I want to move this window all the way into the center (vertically and horizontally)

Answer Source


I got something like this plain javascript straight from google search, we can do it in jquery in much simpler way but try someting like this

var myWindow;

function openCenteredWindow(url) {
    var width = 400;
    var height = 300;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    myWindow = window.open(url, "subWind", windowFeatures);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download