javascript打开一个页面 然后然页面居中显示

var url = htmUrl;
var top = (screen.availHeight - h)/2;
var left = (screen.availWidth - w)/2;
var p = "scrollbars=0,status=0,menubar=0,resizable=2,location=0";
var params = "top=" + atop + ",left=" + aleft + ",width=" + awidth + ",height=" + aheight + "," + p ;
win = window.open(url,'SampleName',params);
win.focus();

screen.availHeight 和 availWidth 分别获取屏幕的大小

你可能感兴趣的:(JavaScript)