Open Centered Popup Window (JavaScript)

The following script will open a centered popup window, maximum size 800 x 600. If the user has a resolution lower than 800 x 600, it will fill the screen.

function openWin(page){
     // width
     w = (screen.width>800) ? 800 : screen.width;
     // height
     h = (screen.height>600) ? 600 : screen.height;
     // left (centered)
     l = (screen.width-w)/2;
     // top (centered)
     t = (screen.height-h)/2;
     // open new window
     newWin = window.open(page,'newWin','left='+l+',top='+t+',width='+w+',height='+h);
}

Comments

Popular posts from this blog

Select box manipulation with jQuery

Basic Excel Spreadsheet Generation (ASP/ASP.NET)

Link: HTML Agility Pack (.NET)