window.open to center of screen

后端 未结 4 735
青春惊慌失措
青春惊慌失措 2021-02-05 13:47

I am using window.open to open a popup window like so:

4条回答
  •  醉话见心
    2021-02-05 14:17

    Also you can try:

    $('a.popup-window').on('click', function(){
        var w = 880, h = 600,
            left = Number((screen.width/2)-(w/2)), tops = Number((screen.height/2)-(h/2)),
            popupWindow = window.open(this.href, '', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=1, copyhistory=no, width='+w+', height='+h+', top='+tops+', left='+left);
        popupWindow.focus(); return false;
    });
    

    And call:

    Open in new window
    

提交回复
热议问题