window.open函数可以很方便的弹出一个窗口,但是如果没有指定left和top参数,则窗口默认会显示在屏幕的左上角,看上去很不美观,下面给出能够让窗口位置显示在屏幕正中央的方法.
function openwin(url, name, width, height) {
var xx = (window.screen.width - width) / 2;
var yy = (window.screen.height - height) / 2;
if(name==null)name="_blank"
var winObj = window.open(url, name, "height=" + height + ", width=" + width + " , toolbar=no, " + "menubar=no, scrollbars=yes , resizable=yes," + "location=no, status=no");
winObj.opener = window;
return winObj;
}