Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Window | Q1519 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.