vedi se possono servire
codice:
/*--------------------------------------------------------------------
Per centrare una finestra rispetto allo schermo
fornendo la larghezza e l'altezza della finestra,
restituisce un oggetto con le proprieta x e y
---------------------------------------------------------------------*/
function CentraRispettoSchermo(w, h)
{
var x = Math.ceil((window.screen.width - w ) / 2);
var y = Math.ceil((window.screen.height - h) / 2);
return {'x':x, 'y':y};};
/*--------------------------------------------------------------------
Per centrare una finestra rispetto alla finestra madre
fornendo la larghezza e l'altezza della finestra,
restituisce un oggetto con le proprieta x e y
---------------------------------------------------------------------*/
function CentraRispettoFinestraMadre(w, h)
{
var ax, ay, aw, ah, x, y;
ax = window.screenLeft;
ay = window.screenTop;
aw = window.document.body.offsetWidth;
ah = window.document.body.offsetHeight
x = ax + Math.round((aw -w)/2);
y = ay + Math.round((ah -h)/2);
return {'x':x, 'y':y};};
da richiamare così:
codice:
var F = null;
function Button1_onclick()
{
var h = 300, w = 300;
var a = CentraRispettoSchermo(w, h);
F = window.open("?", "popup", "width=" + w + "px, height=" + h + "px, top=" + a.y + "px, left=" + a.x + "px, ");
}