中间对齐窗口打开与窗口.在非IE浏览器中打开

Center aligning windows opened with window.open in non IE browsers

本文关键字:窗口 浏览器 IE 在非 中间 对齐      更新时间:2023-09-26

我正在打开一个带有窗口的新页面。打开,我发现我只能用以下代码在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);

windowFeatures中的left声明前缺少逗号:

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);