当前位置:asp编程网>技术教程>Javascript教程>  正文

弹出窗体

2010-02-12 17:12:02   来源:    作者:佚名   浏览量:1955   收藏

//居中弹出窗体
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]



关于我们-广告合作-联系我们-积分规则-网站地图

Copyright(C)2013-2017版权所属asp编程网