我正在用window.open打开一个新页面,我发现我只能使用以下代码在IE中水平居中。它很乐意在Chrome,Firefox和Safari中垂直居中,但就是这样。关于可能导致这种情况的任何想法?
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);
答案 0 :(得分:1)
left
内的windowFeatures
声明之前缺少逗号:
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);