Pop-up Window - centred
<html>
<head>
<title>Pop-up</title>
<script language="javascript">
<!--
function PopupWin(page,IEWidth,IEHeight,NNWidth,NNHeight) {
var MyBrowser = navigator.appName;
if (MyBrowser == "Netscape") {
var myWinWidth = (window.screen.width/2) - (NNWidth/2);
var myWinHeight = (window.screen.height/2) - ((NNHeight/2) + 50);
var myWin = window.open(page,"MainWin","width=" + NNWidth + ",height=" + NNHeight + ",screenX=" + myWinWidth + ",screenY=" + myWinHeight + ",left=" + myWinWidth + ",top=" + myWinHeight + ",scrollbars=yes,toolbar=0,status=1,menubar=0,resizable=0,titlebar=no");
}else {
var myWinWidth = (window.screen.width/2) - (IEWidth/2);
var myWinHeight = (window.screen.height/2) - ((IEHeight/2) + 50);
var myWin = window.open(page,"MainWin","width=" + IEWidth + ",height=" + IEHeight + ",screenX=" + myWinWidth + ",screenY=" + myWinHeight + ",left=" + myWinWidth + ",top=" + myWinHeight + ",scrollbars=yes,toolbar=0,status=1,menubar=0,resizable=0,titlebar=no");
}
myWin.focus();
}
//-->
</script>
</head>
<body>
<a href="javascript:PopupWin('http://www.java2s.com',300,400,300,400)">New Window</a><br>
</body>
</html>
Related examples in the same category