Closed Thread Icon

Topic awaiting preservation: Refresh parent window and Close child window problem Pages that link to <a href="https://ozoneasylum.com/backlink?for=8955" title="Pages that link to Topic awaiting preservation: Refresh parent window and Close child window problem" rel="nofollow" >Topic awaiting preservation: Refresh parent window and Close child window problem\

 
Author Thread
Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 11-24-2003 01:40

Hi, guys. I am having a hard time to refresh parent window and close child window.
I have been developing a forum using ASP and Javascript.
When reply, it opens child window. Then when user click submit, close child window itself then refresh parent window. It is what I am after.
In my code, I did like:

code:
'This is Javascript function to refresh parent window. 
'This exists in <head>
Response.write("<script>")
Response.write("function do_Refresh_hiro(){")
Response.write("location.href ='Message.asp?NID="&PID&"';")
Response.write("}")
Response.write("</script>")


'In body there are Javascript to do that funtion and close the window itself.
Response.Write("<html><script>window.opener.do_refresh_hiro();window.close();</script></html>")



Always, window.opener.do_refresh_hiro() causes a error. It said:

quote:
Object doesn't support this method or property



But I guess I can say window.opener.funcitonname, cann't I?
Do you have any idea what is wrong?
Please help.


Hiroki Kozai

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 11-24-2003 03:28

you are trying to invoke your function as a method of the window object, which it is not. Try just a regular call to your function:

<script>do_refresh_hiro();window.close();</script>


Is your forum using a database for a backend? I tried to code one using flat-files and almost drowned in a sea of multidimensional arrays.....Things got much simpler when I decided to use MySQL.



/* Sure, go ahead and code in your fancy IDE. Just remember: it's all fun and games until someone puts an $i out */

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 11-24-2003 04:27

Hi, many thanks for yoru reply.
I am afraid still not working yet.
Now child window close itself but doesn't refresh parent window.
Do you see any other points?
Cheers.

Hiroki Kozai

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 11-24-2003 06:17

Let's have a look at this do_refresh_hiro() function and maybe we can get to the bottom of this.... And which page contains this function, parent or child?

/* Sure, go ahead and code in your fancy IDE. Just remember: it's all fun and games until someone puts an $i out */

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 11-24-2003 07:21

Hi, Norm. Really thanks for your reply.
Function is in child.
Is that matter which place it is existing?
If so, could you explain why?

And just right now, I cut my funciton into my parent asp file but nothing happens. Just close window.
Hmm.....
Hiroki Kozai

[This message has been edited by Hiroki (edited 11-24-2003).]

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 11-24-2003 16:01

Hi,

you could do the following:
<html>
<script language='JavaScript'>
function do_Refresh_hiro(){
window.opener.location.href ='Message.asp?NID="&PID&";
}
</script>
<body onLoad='do_Refresh_hiro()'>
</body>
</html>

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 11-24-2003 16:32

the reason I asked about the functions location is because I wanted to know if you were calling it from the same document as it was declared in.

It looks to me like Yossi's solution should work for you. It is kind of hard to tell where your problem lies unless you actually POST THE CODE FOR YOUR FUNCTION.

sorry about raising my voice.... I woke up grumpy this AM.



/* Sure, go ahead and code in your fancy IDE. Just remember: it's all fun and games until someone puts an $i out */

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 11-24-2003 20:51

Hi, Yossi . Hi, Norm. Good morning from Nz.
How are you today? Many many thanks for your helps. I really appreciate that.
Hi, Yossi. I tried it but if I do so, that function always tried to refresh window.
And Norm. I posted my function in my first post.
Now my fuction is existing in parent asp file like this:

code:
Title=Session("tom") 
PID = Session("jerry")
Response.write("<script>")
Response.write("function do_Refresh_hiro(){")
Response.write("location.href ='Message.asp?NID="&PID&"';")
Response.write("}")
Response.write("</script>")



And in child file, I am calling function do_Refresh_hiro() like this:

code:
Response.Write("<html><script>do_Refresh_hiro();window.close();</script></html>")



And now even child window doesn't close herself.
Could you see something wrong????


Hiroki Kozai

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 11-24-2003 21:33

<html>
<script language='JavaScript'>
function do_Refresh_hiro(){
window.opener.location.href ='Message.asp?NID="&PID&";
}
</script>
<body onLoad='do_Refresh_hiro();window.close();'>
</body>
</html>

Your code try to refresh the child window and close it right after the call to refresh.
If you want to refresh the opener, use the code above.
If you want to refresh the child (active window), drop the "window.close()" and the "opener." from the code.

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 11-24-2003 21:48

Hi, Yossi. How are you today?
Many thanks for your immediate reply.
Well, I want to close child window. And I want to refresh parent window.
In your code:

code:
<body onLoad='do_Refresh_hiro();window.close();'>


It has to be in parent body tag, isn't it? It seems to close parent window after do function., isn't it?
I will try it.
Cheers.

Hiroki Kozai

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 11-24-2003 21:48

Hiroki: have you searched in the FAQ ? have you introspected the window.opener ? have you asked Google, searched on forums ... that problem is older than my grandMa and whenever I encounter a similar one I can't bear to get stuck more than 5 minutes. Really.

...well, here comes a ground breaking piece of code, to be put in the child window, that works in IE6.0 and FB0.7

code:
function reloadOpenerAndClose()
{
self.opener.location.reload()
self.close()
}

I'm really too kind. As I said above that problem have been solved zillion times before and apparently, you didn't even took ( I'm tempted to say again ) few minutes to search on the web. Sorry to say that but I definitely think that if there's something wrong, it's YOU. When will you try your best before moaning for a kind soul to write the code for you ? Do yourself a favor : gain in autonomy.

Just by curiosity, are you a student or are you already in position in web dev. company ? If you're working for a company, which I doubt in regard of the time of your first post, I wonder how you'll explain that it took you 19 hours to solve that problem.

Mathieu "POÏ" HENRI

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 11-25-2003 01:41

Hi, guys. Many thanks for your help.
Now it seems to works fine.
I have to test it again.
In my child window file, there are unneccesary <html></html>
I deleted it then works all right.
Thanks.


Hiroki Kozai

« BackwardsOnwards »

Show Forum Drop Down Menu