Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1519 How can I open the browser window at a relative-to-screen size and center it all in the same script?

You are here: irt.org | FAQ | JavaScript | Window | Q1519 [ previous next ]

Try:

<script language="JavaScript"><!--
var w = 640/3, h = 480/3, cw = w/2, ch = h/2;

if (window.screen) {
    w = Math.floor(screen.availWidth/3);
    h = Math.floor(screen.availHeight/3);
    cw = Math.floor((screen.availWidth-w)/2);
    ch = Math.floor((screen.availHeight-h)/2);
}

window.open('./','popup','width='+w+',height='+h+',top='+ch+',left='+cw);
//--></script>

Feedback on 'Q1519 How can I open the browser window at a relative-to-screen size and center it all in the same script?'

©2018 Martin Webb