Forum Moderators: open

Message Too Old, No Replies

pop-up windows

Screen position is not what I need

         

circuitjump

5:01 am on Feb 11, 2002 (gmt 0)

10+ Year Member



Hi all,
I'm having a problem with my pop-up window. When pop-up window opens the page, it opens it to the top left. Is there anyway to open the page on the pop-up window in the center?

If you need to see it send me sticky mail

thanks :)

tedster

5:35 am on Feb 11, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Exact centering is a bit complex, because different people may have different sized windows open. But you can easily control the pop-up's position in terms of how many pixels in from the left and down from the top.

This is declared in the "features" string for the window.open() method. You need four parameters (to cover both IE and Netscape.) To open a new pop-up positioned at 150, 100 the code would be:

window.open(url,windowname,www,hhh,left=150,top=100,screenX=150,screenY=100)

(edited by: tedster at 6:41 am (utc) on Feb. 11, 2002)

circuitjump

5:48 am on Feb 11, 2002 (gmt 0)

10+ Year Member



cool,
I'm glad someone is still up this late

Thanks :)

circuitjump

5:12 am on Feb 13, 2002 (gmt 0)

10+ Year Member



New question?
If I have a pop-up window and I want it to open another pop-up window on top of that one, how do I go about doing that?

tedster

7:54 am on Feb 13, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Same way you open a new pop-up from any window. Nothing special needed, just make sure the new pop-up has a new windowname.

<added> Also, your first pop-up may dive to the bottom of the window stack and get lost under the original main window. That's a problem I have yet to solve.</added>

circuitjump

2:48 pm on Feb 13, 2002 (gmt 0)

10+ Year Member



I've been doing a site with a lot of pop-up windows and really did'nt think of changing the "name".

Thanks tedster

gethan

3:14 pm on Feb 13, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<added> Also, your first pop-up may dive to the bottom of the window stack and get lost under the original main window. That's a problem I have yet to solve.</added>

[perl]
newwin = window.open(url,windowname,www,hhh,left=150,top=100,screenX=150,screenY=100)
newwin.focus();
[/perl]

If you already have a window named windowname it will now jump back to the front again.

HTH.

bruhaha

3:45 pm on Feb 13, 2002 (gmt 0)

10+ Year Member



Also, your first pop-up may dive to the bottom of the window stack and get lost under the original main window.

I have not been able to make gethan's solution to this to work consistently.
But I've never had any problem if I put the following in the code for the new window's own page:

<body onLoad="window.focus()">

tedster

5:56 pm on Feb 13, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the tips. I'm amazed that focusing the second pop-up keeps the first pop-up positioned above the main page in the window stack -- but in my testing so far, it has. Nice one.