日期:2014-05-19  浏览次数:20545 次

window.open 怎么样打开一个绝对居中的 窗口可以使用在任何分辨率下
window.open   怎么样打开一个绝对居中的   窗口   可以使用在任何分辨率下
window.open   怎么样打开一个绝对居中的   窗口   可以使用在任何分辨率下
window.open   怎么样打开一个绝对居中的   窗口   可以使用在任何分辨率下

------解决方案--------------------
function openWindow(url,sname,swidth,sheight,sreplace,sclose)
{
var objNewWin;
var top = (screen.availHeight / 2) - (sheight / 2);
var left = (screen.availWidth / 2) - (swidth / 2);
if (swidth== " ") swidth = "790 ";
if (sheight== " ") sheight = "480 ";
if (sreplace== " ") sreplace = false;
if (sclose== " ") sclose = false;
objNewWin = window.open(url,sname, "fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width= " + swidth + ",height= " + sheight + ",top= " + top + ",left= " + left, sreplace);
//alert(objNewWin.opener.dialogLeft);
// + "aaa " + objNewWin.opener.screenTop);
if (sclose) window.close();
objNewWin.focus();
}