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!

On a certain event I open 2 windows

Status
Not open for further replies.

avivit

Technical User
Jul 5, 2000
456
IL
On a certain event I open 2 windows, when one is opened instead of the opener. Then I want the second (pop-up)to be closed onload of the first window (i.e - after loadind is finished), if it was not cosed manually of course.
It doesn't work. Can someone please help?

The opener page:
- - - - - - - - - -
function openIt()
{yyy = window.open("x.html","OkWin","width=300,height=100,left="+Math.floor((screen.width-300)/2)+",top="+Math.floor((screen.height-10)/2));

yyy.focus();
}

The page slowly loaded instead of the opener:
- - - - - - - - - - - - - - - - - - - - - -
<script>
function checkTheWin()
{ if (!yyy.closed)
yyy.close();
}
</script>

<body onload=&quot;checkWaitWin(&quot;>

Thanks
Avivit
 
oops, I forgot (I hate when people r doing that)to show another line, which opens the 2nd win as well:

The opener page:
- - - - - - - - - -
function openIt()
{yyy = window.open(&quot;x.html&quot;,&quot;OkWin&quot;,&quot;width=300,height=100,left=&quot;+Math.floor((screen.width-300)/2)+&quot;,top=&quot;+Math.floor((screen.height-10)/2));

yyy.focus();
parent.down.location.href=&quot;show.asp?&quot; //Slowly loaded
}

 
Could you put in your actual code because I can't tell where the mistakes are, cause here you have assigned both windows to the same variable!(yyy)

This code works though:

/* function to open the windows */

function opener(){
one = open('','','menubar=no');
two = open('','','menubar=no');

two.onLoad = checkTheWin();

}
/* function for closing first window */

function checkTheWin(){
if(!one.closed){two.document.write('closing win_1');
one.close()}
else{}
}



So when the second one opens, and loads it calls a function belonging to the opener of them both.

Hope it helps
-Ben &quot;Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer&quot;
 
Thanks, bangers.
I assume you use all of these in the same page.right?
That is not my case. My case is when one page in a cetain frame opens a small window and also opens another page in another frame.
The opener is one frame, and I need to close the window from the the other frame.

Always happy to hear ideas.
 
Here is the solution:

The opener page which opens a pop-up named yyy and asp page in a 2nd frame :
- - - - - - - - - -
function openIt()
{yyy = window.open(&quot;x.html&quot;,&quot;OkWin&quot;,&quot;width=300,height=100,left=&quot;+Math.floor((screen.width-300)/2)+&quot;,top=&quot;+Math.floor((screen.height-10)/2));

yyy.focus();
parent.down.location.href=&quot;show.asp?&quot; //Slowly loaded
}

The asp page slowly loaded instead of the 2nf frame:
- - - - - - - - - - - - - - - - - - - - - -
<script>
function checkTheWin()
{ if (!parent.topFrame.yyy.closed&amp;&amp;parent.topFrame.yyy)
parent.topFrameyyy.close();
}
</script>

<body onload=&quot;checkTheWin()&quot;>
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top