2015-05-18 44 views

回答

0

你必須放置窗口在屏幕上之前,計算出屏幕的寬度和高度。

事情是這樣的:

function popupwindow(url, title, w, h) { 
    var left = (screen.width/2)-(w/2); 
    var top = (screen.height/2)-(h/2); 
    return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left); 
} 

popupwindow('http://google.com','Test Frame',600, 800) 

As answered here,類似的堆棧溢出後。

相關問題