newWindow 弹出的新窗口居中显示

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>test</title>
<meta name="keywords" content=""/>
<meta name="description" content=""/>
<link type="text/css" rel="stylesheet" href="http://j.laohe360.net/css/pub.css"/>
<script charset="utf-8" type="text/javascript" src="http://j.laohe360.net/js/play.js?001"></script>
<script>
	function newWindow(){
		var iWidth=500; //弹出窗口的宽度;
		var iHeight=400; //弹出窗口的高度;
		var iTop = (window.screen.availHeight-30-iHeight)/2; //获得窗口的垂直位置;
		var iLeft = (window.screen.availWidth-10-iWidth)/2; //获得窗口的水平位置;
		var w = 'height='+iHeight+',width='+iHeight+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no';
		window.open('http://www.baidu.com','',w)
	}
</script>
</head>
<body>


<div id="tpsp">
	<a href="#" onclick="newWindow();">aaaaaaaaaaaaaaa</a>

</div>


</body>
</html>

 

posted @ 2014-12-05 21:36  天道酬勤,坚持!  阅读(638)  评论(0编辑  收藏  举报