Entry
How do I open a window centered?
Jun 12th, 2000 14:38
Martin Honnen,
If you provide a width and a height you can center a window:
function openCentered (url, width, height, windowName, featureString) {
if (!windowName)
windowName = '';
if (!featureString)
featureString = '';
else
featureString = ',' + featureString;
var x = Math.round((screen.availWidth - width) / 2);
var y = Math.round((screen.availHeight - height) / 2);
featureString = 'left=' + x + ',top=' + y + ',width=' + width
+ ',height=' + height + featureString;
return open (url, windowName, featureString);
}
Example:
openCentered('http://JavaScript.FAQTs.com', 300,
200, 'faqts', 'resizable=1,scrollbars=1')