Entry
How do I open a window in the center of the parent window?
Feb 15th, 2009 21:38
Inschi jelii, Martin Honnen,
This is only possible precisely with NN4+ which provides
window.outerWidth/outerHeight
while IE doesn't provide that:
function openCentered (url, width, height) {
if (document.all) {
var x = window.screeLeft;
var y = window.screenTop;
var w = window.document.body.offsetWidth;
var h = window.document.body.offsetHeight;
}
else {
var x = window.screenX;
var y = window.screenY;
var w = window.outerWidth;
var h = window.outerHeight;
}
var cx = x + Math.round((w - width) / 2);
var cy = y + Math.round((h - height) / 2);
return open (url, null, 'left=' + cx + ',top=' + cy + ',width=' +
width + ',height=' + height);
}
//Example
openCentered('http://JavaScript.FAQTs.com', 300, 300)
http://lahjatideoita.blogspot.com
http://ideaspara-regalar.blogspot.com
http://idearegalo1.blogspot.com
http://geschenkeidee.blogspot.com
http://darkovenapady.blogspot.com