2013-03-25 51 views
1

我使用window.open打开了一个新页面,我发现只能在IE中使用下面的代码对其进行水平居中。它将在Chrome,Firefox和Safari中高兴地垂直居中,但就是这样。有什么想法可能造成这种情况?在非IE浏览器中使用window.open打开的中心对齐窗口

var left = Number((screen.width/2)-(700/2)); 
var top = Number((screen.height/2)-(500/2)); 

var windowFeatures = 'channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,width=700,height=500,top='+top+'left='+left; 
window.open('access-modal.html', '', windowFeatures); 

回答

1

里面有windowFeaturesleft声明之前缺少逗号:

var left = Number((screen.width/2) - (700/2)); 
var top = Number((screen.height/2) - (500/2)); 

var windowFeatures = 'channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,width=700,height=500,top=' + top + ',left=' + left; 
window.open('access-modal.html', '', windowFeatures); 
相关问题