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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open two windows with Window.Open()

Status
Not open for further replies.

jfrost10

Programmer
Jun 3, 2001
2,004
CA
Hey guys,

I was wondering if anyone knows if its possible to have two child windows from one parent.

Here's what I'm encountering:
1. I use window.open() to open a popup window.
2. I use window.open() again to open a different popup window
3. The second page I'm opening just opens in the first window (I can only ever have one child window at a time)

Is there a way around this?

Thanks guys!

Jack
 
I haven't really looked into this much so I am not sure if it is possible. The trick is to give the second window a different name. Kind of like how forms have names so do windows. If you can specify that name then as long as a window with the same name is not open then a new window will open. That'l do donkey, that'l do
[bravo]
 
Thanks Zar, I'll try different names in the js and see if it works (right now I'm not naming it anything, so that could very well be the fix)
:)

Jack
 
hopefully anyway hey ;-) That'l do donkey, that'l do
[bravo]
 
rather than the name, the handle here is going to be the key:

function popEm(){
var x = window.open('someWin.htm','1win','width=50,height=50');
var y = window.open('someOtherWin.htm','1win','width=50,height=50');
x.moveTo(0,0);
y.moveTo(200,200);
}

:)
paul
penny1.gif
penny1.gif
 
Hey Jack on my system your function still closes the first window before opening the second. I changed it around a bit and this does work.

function popEm(){
var x = window.open('someWin.htm','1win','width=50,height=50');
var y = window.open('someOtherWin.htm','2win','width=50,height=50');
x.moveTo(0,0);
y.moveTo(200,200);
}
That'l do donkey, that'l do
[bravo]
 
oops sorry paul. I didn't even look at your name when you posted. I thought that was Jack I was speaking to.

Not to be argumentative but the solution also works as follows with the same handles.

function popEm(){
var x = window.open('someWin.htm','1win','width=50,height=50');
x.moveTo(0,0);
var x = window.open('someOtherWin.htm','12win','width=50,height=50');
x.moveTo(200,200);
}
That'l do donkey, that'l do
[bravo]
 
hmmm... interesting. must be because of the dual declaration -- newing up the x var again with the var keyword.

Thanks for the info, though. I didn't know that. :)
penny1.gif
penny1.gif
 
I am guessing that is what it is I am not really sure on the specifics only that it has worked for me.

No problemo That'l do donkey, that'l do
[bravo]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top