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

Child windows mark2

Status
Not open for further replies.

siuk

Programmer
Aug 23, 2001
38
GB
Hi sorry if there was some confusion on the last post.

But all I want to be able to do is close a child window.

If I open a window called 'mywin'. How can I then close this window?
-----------------------------------------------------------
var mywin = window.open('-----------------------------------------------------------
This will open the window correctly.
-----------------------------------------------------------

<a href=&quot;javascript:mywin.close();&quot;>close child window</a>

However the code above wont close my window :(

can anyone help me?

If anyone knows it would also be helpful to know how to load child window functions from the parent window.

Many Thanks
 
maybe you can use this!
This was originally a german script.
I translated it into English, I hope I haven't forgotten anything.
mfg borkert
<html>
<head>

</head>

<body>
<b>open and close window</b>
<p>
<body onload=&quot;demo()&quot; onunload=&quot;zu()&quot; >

<script language=&quot;JavaScript&quot;>
<!--


win = null;
function demo()
{
win = window.open(&quot;popup.php&quot;,&quot;demo&quot;,&quot;toolbar=no,menubar=no,top=0,left=0,width=300,height=300&quot;)
win.focus();
}
function zu()
{
if (win != null)
if (!win.closed)
win.close();
}
//-->
</script>

<a href=&quot;#&quot; onclick=&quot;demo()&quot;>open window</a> <a href=&quot;#&quot; onclick=&quot;zu()&quot;>close window</a>
<p>

<p>

<!--
//-->
</SCRIPT>

</body>
</html>
 
yea, just like borkert wrote, this variable have to be global (it have to be defined outside of a function)


>>If anyone knows it would also be helpful to know how to load child window functions from the parent window

just the same:

mywin.functionname();

(if this mywin is global) Victor
 
thanks alot guys - it was al about the global vars DOH! ;0)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top