469,572 Members | 1,605 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

How will Child Window[called using window.open] Call Functions in Parent Window

Hi!
I just want to ask if it possible to call functions in parent window if the child window is created.
Below is sample:
//--------------------------------------------------------------------------------//
<html>
<head>
<title></title>
<script language="JavaScript">
var win;

function popup()
{
win = window.open("popup.html", "test", "status=0");
win.document.write("<input type='button' value='child click' onclick='popup2()'>");

win.document.close();
}

function popup2()
{
alert('true');
}

</script>
</head>
<body>
<input type='button' value='parent click' onclick='popup()'>
</body>
</html>

//--------------------------------------------------------------------------------//

Once 'parent click' button is clicked, popup.html will show that contain 'child click' button.
All I want is that once 'child click' button is clicked, I want to call function popup2() created in the parent window.

Please help for additional information I missed. Thanks in advance!
Nov 9 '06 #1
2 9626
vee10
141 100+
hi,

just write

win.document.write("<input type='button' value='child click'
onclick='opener.popup2()'>");

then popup2() in the child window will be called but this alert box will be appeared in the parent window if u want appear in the child window then write

function popup2()
{
win.alert('true');
}

then alert will be appeared in the child window
















Hi!
I just want to ask if it possible to call functions in parent window if the child window is created.
Below is sample:
//--------------------------------------------------------------------------------//
<html>
<head>
<title></title>
<script language="JavaScript">
var win;

function popup()
{
win = window.open("popup.html", "test", "status=0");
win.document.write("<input type='button' value='child click' onclick='popup2()'>");

win.document.close();
}

function popup2()
{
alert('true');
}

</script>
</head>
<body>
<input type='button' value='parent click' onclick='popup()'>
</body>
</html>

//--------------------------------------------------------------------------------//

Once 'parent click' button is clicked, popup.html will show that contain 'child click' button.
All I want is that once 'child click' button is clicked, I want to call function popup2() created in the parent window.

Please help for additional information I missed. Thanks in advance!
Nov 9 '06 #2
Thanks for the reply.

Is it possible also to have a javascript function handling "opener.someFunctions()". For instance, I have lots of buttons calling function upon onclick and since string inside win.document.write("some string here....") is also dynamically generated.

What I mean is that, on the parent window, there’s a lot of win.document.write("<input type='button' value='click me2!' onclick='someFunctions()'>") and inside child window, there must be a code that generates "opener.someFunctions()".

Is there any way to have javascript code for the child window to make it?

I appreciate for responses. Thanks in advance.
Nov 9 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by John Dalberg | last post: by
8 posts views Thread by mike | last post: by
5 posts views Thread by midnight_use_only | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.