Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Script Window Closing Issue - Immediate Help Required

 
A Smith
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I redirect to a page on which I've the following piece of code on a function as follows. Let me call this page "C". I call this function on the load of this page.


function fnClose()
{
window.parent.opener=window;
window.parent.close();
}




The reason why I'm setting like window.parent.opener=window is to avoid the warning message "The web page you are viewing is trying to close the window...". If I remove that line, then I get the above warning message.

Assume that I'm on a page called "A". From "A", I reach "B" by clicking a hyperlink.
And on "B" too,I've a hyperlink . On clicking this hyperlink, I reach a servlet that in turn redirects to "C" where I have the above piece of code to close my window.

This works very fine.

Now Assume that I've a second hyperlink in "A" itself. And I click to do something and come back to "A" once again. Now I reach "B" from "A" by clicking the first hyperlink. Now I click the hyperlink in "B" to reach "C". Now no JavaScript error is thrown, but window is not closed why?

In first case:
A--B--Servlet--C (At C, I close)-Close working fine

In second case:
A--A--B--Servlet--C (At C, I close)-What I get is a white page of C - the window is not closed. Why? I am puzzled. Could anyone provide me a quick solution?

Aravind
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sounds like you have an issue of loosing reference between the windows.

Not sure exactly....

That is what you get for trying to close the window without the prompt! :roll:

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic