This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes check if a window with a particular name is already opened Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "check if a window with a particular name is already opened " Watch "check if a window with a particular name is already opened " New topic
Author

check if a window with a particular name is already opened

Mahesh Shiwani
Greenhorn

Joined: Oct 04, 2004
Posts: 10
Hi All,

i want to check whether a popup (or any other window) with a particular name say 'x' is already opened or not. And twist in story is that i am opening child window from two(or more) different parent screens, and all the time child window name is same. so i want to check whether child is already opened, no matter from any parent screen.

Thanks & Regards,
Mahesh Shiwani.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6


You may find issues when changing pages since you loose objects.

Eric
Mahesh Shiwani
Greenhorn

Joined: Oct 04, 2004
Posts: 10
you are absolutly right Eric, when i change pages i loose the object and that is the problem. is there any way that i can check in windows registry for some other place say "whether any window in this system (PC) with name 'X' is already opened or not".... looks simple question but till now no answers.. :-))
Thanks & Regards,
Mahesh......
Premil Jacob
Ranch Hand

Joined: Sep 10, 2004
Posts: 30
u could write a value to a cookie when the window is opened and removing the value when the window is closed.


Thanks,<br />Premil<br /> <br />SCJP 1.4
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Only real way to do it is to use a hidden frame, but that can kill the site.

You could use and onunload handler and close the window when the page changes.

Eric
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 815
Thanks for this posting. I had posted a similar question before and people have said check the object, check the object. This doesn't work when (as stated) you change pages or resubmit the form you're on. Thanks Eric for the helpful advice.

Rob
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 815
In addition to this, if I'm using a pop-window and I write to it using a javascript function how can I clear the window when writing to it the second, third, fourth, etc.., time? Thanks for the help.

Rob
Farouk Sherefudheen
Ranch Hand

Joined: Jan 27, 2004
Posts: 32
This code u provided calls window.open first and then does the check.
So every time this will open the window whether there is a window present or not already.

Please reply
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Originally posted by Farouk Sherefudheen:
This code u provided calls window.open first and then does the check.
So every time this will open the window whether there is a window present or not already.

Please reply


That is just lines of an example, it was not a working code.....
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Originally posted by Rob Pike:
In addition to this, if I'm using a pop-window and I write to it using a javascript function how can I clear the window when writing to it the second, third, fourth, etc.., time? Thanks for the help.

Rob


All I would do is:


That replaces the content and the back button will still access the content in the window. If you do not want that then you would want to use document.body.innerHTML = "your content"

Eric
 
 
subject: check if a window with a particular name is already opened
 
Similar Threads
Regarding response.sendredirect
parent-child window relationship
Parent-Child window relationship
issue with session on restart of server
status of child window