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!

Centering the popup window

Status
Not open for further replies.

sil3nt2004

Programmer
Aug 17, 2004
5
ZA
Hi guys!

Can anybody please tell me how to go by centering a popup window on the screen.

I want to be able to center the popup window no matter the screen resolution.

Here is the javascript I use to make my popup windows:

<SCRIPT LANGUAGE="JavaScript">
function open_window(url) {
mywin = window.open(url,
"Window_name",
'width=650,height=450,top=400,left=400,toolbar=0,location=0,menubar=0,scrollbars=0,resizable=0');
}

Thanks in advance...

sil3nt
 
Please take a look of faq216-3542, you will find the answer.
 
This works for me in IE6:

Code:
function popupMessage()
{
 var width=200;
 var height=100;
 var popup = window.open("popup.html", "_new", 

"width="+width+",height="+height+",top="+(screen.height/2 - 

height/2)+"left="+(screen.width/2 - width/2));
 if(popup) popup.focus();
}

'hope that helps.

--Dave
 
Thank you guys!

That pretty much solved my problem!

sil3nt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top