Click to See Complete Forum and Search --> : refreshing the child


Hooman
05-22-2003, 01:13 PM
Hello,

Parent window is calling a function in the child....
The function seems to be done, but no change in the child page....It should show a list of variables in its list box, but no change.
mywin=window.open('test.htm','mywin');
mywin.updatekon(list1);

If I add one ALERT command, before calling the function:

mywin=window.open('test.htm','mywin');
alert("Hi);
mywin.updatekon(list1);

Now it all works perfectly and I have a list in my child listbox.

Any body knows why?
I thought maybe after child opens up for the first time, it doesn't update automatically.

Any comments appreciated..

Mr J
05-22-2003, 01:22 PM
It is probably because the line

mywin.updatekon(list1);

is run before the window has opened and by adding the alert you are in effect pausing the script which gives the window the time to open and load the page.

As an experiment try putting mywin.updatekon(list1) on a timeout


setTimeout("mywin.updatekon(list1)",2000)

See what happens

Hooman
05-22-2003, 01:30 PM
Beautifully Done, Thank you.....
I am also trying to close the parent window, right after that function is done...

I tried your timeout suggestion on it too, it didn't work

setTimeout("mywin.updatekon(list1)",1000) ;
setTimeout("window.close()",3000) ;

Do you know how to close the parent window?

requestcode
05-22-2003, 01:33 PM
Although this is not related to your problem you should not use the same name for your variable and window name. You are using "mywin" for the open and also for the window name. I would change one or the other. It might cause problems. Also, could you place the call for the function in the body tag of the document in your popup? You could use the onLoad event - <body onLoad="updatekon()"> . If you need the value in the variable "list1" you could reference it in the first line of your function like this:
myvar=opener.list1

The term "opener" refers to the window that the popup opened from. You can also call functions in the "opener" window from the child like this: opener.function_name().

Mr J
05-22-2003, 01:45 PM
setTimeout("self.close()",3000) ;

Hooman
05-22-2003, 01:51 PM
Thanks for the comments,
Still it doesn't seem to want to close the window.

function sendit()
{
mywin=window.open('test.htm');
setTimeout("self.close()",3000) ;
}

This function is called from one of the forms in the parent window.
Do you think that might be why it doesn't close out all the window?

Hooman
05-22-2003, 01:52 PM
I don't know what happened it is closing now....

Thanks again from the Webmaster, and also Mr J
Grateful,

Hooman
05-22-2003, 01:54 PM
Sorry, it seems like I have still problems closing the parent page,
Do you think it's because of having several Frames in it?

thanks,

Mr J
05-22-2003, 05:10 PM
Are you trying to close the frameset?

If so try this.

Copy the following into a new page and save as closeme.htm in the same folder as your popup page


<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
</HEAD>
<BODY>
<script language=JavaScript type=text/JavaScript>
<!--
window.opener = top;
setTimeout("self.close()",50)
// -->
</script>
</BODY>
</HTML>




In the popup page add the following script



<script language=JavaScript type=text/JavaScript>
<!--
function hmm(){
opener.parent.location="closeme.htm"
}
onload=hmm
// -->
</script>

Hooman
05-22-2003, 06:56 PM
Mr. J

thank you very much for your comments.
How can I call 2 functions in my onLoad?
I'll try to call the second function in the first one that I'm calling in onLoad.

But in General, for onLoad/onClick/... is there a way to call 2 or 3 functions?

Many thanks again,

pyro
05-22-2003, 07:01 PM
<body onload="functionOne(); functionTwo();">

Mr J
05-23-2003, 02:13 PM
I have done a bit of experimenting since my last reply and find the following scripts work.

Close frameset from within a frame

In the frame closing the frameset.

<script language=JavaScript type=text/JavaScript>
<!--
function close_all(){
parent.opener = top
parent.close()
}
// -- >
</script>

Use an event to call close_all()

Close frameset from a popup

In the popup page.

<script language=JavaScript type=text/JavaScript>
<!--
function close_frameset(){
opener.parent.opener = top
opener.parent.close()
}

window.onerror=sh
function sh(){
return true
}

onload=close_frameset
// -- >
</script>

Hooman
05-23-2003, 03:21 PM
Thanks alot Mr.J
I'll try it on Tuesday, when I'm back to work.