Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to center and resize a window when it loads

Status
Not open for further replies.

mike2003

Programmer
Mar 15, 2003
4
US
Hello all

I am trying to automaticaly resize my window and center it in the screen when it loads.
I know it can be done using window.open(), but i am not using that to open the window. I am trying to see how I can do it using the <body onload>

Thanks
Hope to hear from all of you soon
 
<BODY onLoad=&quot;javascript:changewindow()&quot;>

<SCRIPT LANGUAGE=javascript>
function changewindow(){
window.resizeTo(width,height)
window.moveTo(fromleft,fromtop)}
</SCRIPT>
Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
to center...

<script>
function sizeIt(){
sWidth = screen.width
sHeight = screen.height
winWidth = sWidth/2 //or whatever
winHeight = sHeight/2 //or whatever

window.resizeTo(winWidth ,winHeight)
window.moveTo((sWidth/2) - (winWidth/2),((sHeight/2) - (winHeight/2))
}
</script>
<body onLoad=&quot;sizeIt()&quot;>

Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
 
For future reference, we generally prefer javascript questions be handled over in the javascript forum, this way other people with the same questions will see the answers you ereceive and you a search might show that this question had already been answered before, saving you some time.

-Tarwn [sub]01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101 [/sub]
[sup]29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19[/sup]
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top