HighDots Forums  

Centrare la pop up

Javascript (Italian) Il linguaggio JavaScript (it.comp.lang.javascript)


Discuss Centrare la pop up in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
FrancescoG
 
Posts: n/a

Default Centrare la pop up - 02-17-2005 , 04:33 AM






Come centrare nello schermo una pop up appena aperta?

Ho inserito nella <HEAD> il seguente script:

<script language="javascript">
h=150;
w=400;
sh=screen.height;
sw=screen.width;
document.moveTo(sh/2-h/2,sw/2-w/2);
</script>

ma non funziona.

come mai?



Reply With Quote
  #2  
Old   
FrancescoG
 
Posts: n/a

Default Re: Centrare la pop up - 02-17-2005 , 04:44 AM






trovato l'errore:

document.moveTo(sh/2-h/2,sw/2-w/2);
Quote:
V
window.moveTo(sh/2-h/2,sw/2-w/2);

"FrancescoG" <adso.rose (AT) email (DOT) it> wrote

Quote:
Come centrare nello schermo una pop up appena aperta?

Ho inserito nella <HEAD> il seguente script:

script language="javascript"
h=150;
w=400;
sh=screen.height;
sw=screen.width;
document.moveTo(sh/2-h/2,sw/2-w/2);
/script

ma non funziona.

come mai?





Reply With Quote
  #3  
Old   
ZER0
 
Posts: n/a

Default Re: Centrare la pop up - 02-17-2005 , 04:55 AM



On Thu, 17 Feb 2005 09:44:47 GMT, FrancescoG wrote:

Quote:
document.moveTo(sh/2-h/2,sw/2-w/2);

window.moveTo(sh/2-h/2,sw/2-w/2);
Argh, sei la seconda persona che vedo usare questa "formula".. ma dove
l'avete pescata?

Inoltre hai invertito il left con il top:

window.moveTo(sw/2-w/2,sh/2-h/2);

Preferibilmente:

window.moveTo( (sw-w)/2,(sh-h)/2 );

Meglio ancora:

window.moveTo( (sh-h)>>1,(sw-w)>>1 );

E se possibile:

var h=150,
w=400,
t=(screen.height-h)>>1,
l=(screen.width-w)>>1;

window.moveTo(l,t);

Sarebbe perfetto.


--
ZER0

~ The Tangent Universe collapsed 5954 days, 4 hours, 13 minutes and 44 seconds ago.

on air ~ "Metallica - For whom the bell tolls"


Reply With Quote
  #4  
Old   
ZER0
 
Posts: n/a

Default Re: Centrare la pop up - 02-17-2005 , 05:51 AM



On Thu, 17 Feb 2005 10:55:56 +0100, ZER0 wrote:

Quote:
Inoltre hai invertito il left con il top:
[cut]

Quote:
window.moveTo( (sh-h)>>1,(sw-w)>>1 );
Qui l'ho lasciato invertito io
Sarebbe, ovviamente, come i precedenti. Ovvero:

window.moveTo( (sw-w)>>1,(sh-h)>>1 );

--
ZER0

~ The Tangent Universe collapsed 5954 days, 5 hours, 9 minutes and 23 seconds ago.

on air ~ "Go Betty Go - C'mon"


Reply With Quote
  #5  
Old   
# tHeJoKeR #
 
Posts: n/a

Default Re: Centrare la pop up - 02-17-2005 , 01:58 PM



ma in definitiva come viene?!!?
non l'ho capito!!!

"ZER0" <zer0.shock (AT) libero (DOT) it> ha scritto nel messaggio
news:a63wz3l6blbm$.dlg (AT) ID-171124 (DOT) news.individual.net...
Quote:
On Thu, 17 Feb 2005 10:55:56 +0100, ZER0 wrote:

Inoltre hai invertito il left con il top:

[cut]

window.moveTo( (sh-h)>>1,(sw-w)>>1 );

Qui l'ho lasciato invertito io
Sarebbe, ovviamente, come i precedenti. Ovvero:

window.moveTo( (sw-w)>>1,(sh-h)>>1 );

--
ZER0

~ The Tangent Universe collapsed 5954 days, 5 hours, 9 minutes and 23
seconds ago.

on air ~ "Go Betty Go - C'mon"



Reply With Quote
  #6  
Old   
ZER0
 
Posts: n/a

Default Re: Centrare la pop up - 02-21-2005 , 01:15 PM



On Thu, 17 Feb 2005 19:58:44 +0100, # tHeJoKeR # wrote:

Quote:
ma in definitiva come viene?!!?
non l'ho capito!!!
var h=150,
w=400,
t=(screen.height-h)>>1,
l=(screen.width-w)>>1;

window.moveTo(l,t);


--
C'ya,
ZER0 :: coder.gfxer.webDesigner();

"When you have eliminated the impossible, whatever remains,
however improbable, must be the truth." (S.H.)



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.