居中 window.open 与 window.showModalDialog

来源:互联网 发布:大学生支教后收获数据 编辑:程序博客网 时间:2024/05/22 04:31
            var iWidth = window.screen.availWidth - 350;        //弹出窗口的宽度;
            var iHeight = window.screen.availHeight - 350;    //弹出窗口的高度;
            var iTop = (window.screen.availHeight - 30 - iHeight) / 2;    //获得窗口的垂直位置;
            var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;      //获得窗口的水平位置;
            var isChrome = window.navigator.userAgent.indexOf("Chrome") !== -1;
            if (isChrome) {
                   window.open(url, name, 'height=' + iHeight + ',width=' + iWidth + ',top=' + iTop + ',left=' + iLeft +                                      ',toolbar=no,menubar=no,scrollbars=yes, resizable=no,location=no,status=no')
            } else {
                window.showModalDialog(url, name, "dialogWidth=" + iWidth + "px;dialogHeight=" + iHeight +                                      "px;dialogLeft=" +  iLeft + "px");
            }
0 0