//居中弹出窗体
function getwindow(URL,width,height)
{
//根据屏幕居中
window.open(URL,'','width='+width+',height='+height+',top='+(screen.height-height)/2+',left='+(screen.width-width)/2);
//下面是根据页面居中
//window.open(URL,'','width='+width+',height='+height+',top='+(document.body.offsetHeight-height)/2+',left='+(document.body.offsetWidth-width)/2);
//window.open(URL,'','width='+width+',height='+height+',top=250,left='+document.body.offsetWidth/3);
}
---------------------------------------------------------------
弹出窗口实例:
[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>居中弹出窗体</title>
</head>
<body>
<p>
<script language="javascript">
//居中弹出窗体
function getwindow(URL,width,height)
{
//根据屏幕居中
window.open(URL,'','width='+width+',height='+height+',top='+(screen.height-height)/2+',left='+(screen.width-width)/2);
//下面是根据页面居中
//window.open(URL,'','width='+width+',height='+height+',top='+(document.body.offsetHeight-height)/2+',left='+(document.body.offsetWidth-width)/2);
//window.open(URL,'','width='+width+',height='+height+',top=250,left='+document.body.offsetWidth/3);
}
</script>
<a href="#" onClick="getwindow('http://www.aspprogram.cn',400,500)">弹出居中</a></p>
</body>
</html>[/code]