`

弹出窗口居中显示

阅读更多

主要根据窗体跟屏幕大小计算top跟left,

top=(screen.height-height)/2    

 left=(screen.width-width)/2

 

例如:

    buildHtml : function() {

        // 居中显示
        var height = 600;
        var width = 800;
        var top = (screen.height-height)/2;
        var left = (screen.width-width)/2;

        var html = "<div class='panel-padding'><table cellspacing='10'>"
                + "<tr><td><a href='#' onclick=\"window.open('A.html', '1', 'height=" + height + ", width=" + width + ", top=" + top + ",left=" + left + ", toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')\"><b>员工手册</b></a></td></tr>"
                + "<tr><td><a href='#' onclick=\"window.open('B.html', '2', 'height=" + height + ", width=" + width + ", top=" + top + ",left=" + left + ", toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')\"><b>员工手册之补充细则</b></a></td></tr>"
                + "<tr><td><a href='#' onclick=\"window.open('C.html', '3', 'height=" + height + ", width=" + width + ", top=" + top + ",left=" + left + ", toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')\"><b>关于保守商业秘密的规定</b></a></td></tr>"
                + "<tr><td><a href='#' onclick=\"window.open('D.html', '4', 'height=" + height + ", width=" + width + ", top=" + top + ",left=" + left + ", toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')\"><b>员工信息安全手册</b></a></td></tr>"
                + "</table></div>";

        return html;
    }

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics