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

Q1399 How can I open a popup window in the middle of the screen?

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

Q1399 How can I open a popup window in the middle of the screen?

Try the following which works in JavaScript 1.2:

<script language="JavaScript"><!--
function openWindow(width,height) {
    x = (640 - width)/2, y = (480 - height)/2;

    if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }

    window.open('nextpage.htm','newWin','width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x);
}
//--></script>

<form>
<input type="button" onClick="openWindow(100,200)" value="Click Me">
</form>

Feedback on 'Q1399 How can I open a popup window in the middle of the screen?'


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.