1

我正在使用 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);
4

1 回答 1

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);
于 2013-03-26T00:35:44.187 回答