2013-03-25 52 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); 
相關問題