Tuesday, June 2, 2009

Center Alignment of popup window Javascript

How to centralized popup window using Javascript. see the below code.

CODE:
1 :  var OpenWindows = new Object();
2 :  function OpenWin(sPath, w, h)
3 :   {
4 :       l = (screen.width - w)/2-5;
5 :       t = (screen.height - h)/2-20;
6 :       if (l<1) l=0;
7 :       if (t<1) t=0;
8 :       sWindowName = "mainwin_" + w + "_" + h;
9 :       if(OpenWindows[sWindowName]) {
10 :            if(!OpenWindows[sWindowName].closed) OpenWindows[sWindowName].close();
11 :       }
12 :       OpenWindows[sWindowName] = window.open(sPath, sWindowName, "left=" + l + ",top=" + t + ",width=" + w + ",height=" + h + ",scrollbars=no,menubar=no,toolbars=no,status=no");
13 :       return OpenWindows[sWindowName];
14 :  }

No comments:

Post a Comment