File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Opening Windows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Opening Windows" Watch "Opening Windows" New topic
Author

Opening Windows

Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Hi,
Heres what I'm doing... I open a window through javascript on one page but I then submit the form on the old window while the new window is minimized. When the old window returns the old form, I was wondering if there was a way to tell if the new window still existed and if I could overwrite the contents of that window or even close it. The new window is basically a window that displays results from a search. If I minimize the window and get new results from a search I want only those results shown in this window. Does anyone have an suggestion? Both Netscape and IE compatible would be a bonus.
Thanks
Rob
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
play with this and see what you can do with it
if (AlienPop && !AlienPop.closed){
AlienPop.focus();}
else{A1ienPop=window.open()}
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Hi Al,
Thanks for your reply. I was more interested, however, in the fourth argument of the window open method. Supposedly you can set this arg to true or false to overwrite this window with a new URL or overwrite what is there. I know about the clear() but I would like to use that argument. You know anything about this? I've tried it but it didn't seem to work in IE, didnt try NS yet. Thanks for any reply you can give, in advance.
Rob
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I usually do something like this when I want to use the same pop up window for different links. This is just the basic idea
function OpenIT(TheURL){
if (AlienPop && !AlienPop.closed){
AlienPop.document.href=TheURL;
AlienPop.focus();}
else{A1ienPop=window.open(TheURL)}
}
If this does not help you, tell me what you are trying to accomplish and I might be able to help out a little better.
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Hi,
The main browser window is displaying the application I've created. On that window the user can do a city lookup based on keywords. If multiple cities are found a new window is created with all the cities listed as links (i.e. click the link and that city is stored in the city text field). If the user goes back to the main window without closing that window and does another search, the new results are concatenated onto the bottom of the last results in the results window. I realize I can just close the window on blur but I need it kept open so the user can change the city at any point with one of the cities previously found. This new window by the way is not pointing to a specific URL but is created within the body of the script (this is a JSP application). I set up the open like follows :
NewWin = window.open("", "newwin", ".....");
Any suggestions? Thanks in advance.
Rob
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
hi rob,
im facing the same prob..were u able to solve this ?? plz help me with the code..im running out of time..
raj


SCJP, SCWCD, SCBCD, Oracle Certified Professional (SQL n PL/SQL)
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
what are you trying to do exactly?
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
if you want your result to be concatenated to a previos one in existing window, you could:
Have a hidden iframe in your main window - this is where you request will really be submited and response will come to.
After request is done (you got your result) you check, is window closed (see Eric code - I do it all the time).
Another way to check would be to define a boolean in your main window, set it to false initially, set it to true, when you open a window for a result. That result window in ONULOAD handler will set that boolean to false.
So, if window closed your open a new one. If not - do nothing.
Than you create your html to insert into result window and add it to the end of result window innerHTML - something like result.document.body.innerHTML+=newSearchResult
And that you need to call focus() on result window
[ March 24, 2003: Message edited by: Yuriy Fuksenko ]
Hiren Pathak
Greenhorn

Joined: Mar 24, 2003
Posts: 21
Hi Rob,
Here is the simple way to do whatever you want to do. You can give the same name to all your new pop up windows. And just put a "Back" link on that new pop up window. so if you click on that back link you will be directed to the previous search results. so there is no need to concatenate and still you can solve your problem.
Hiren.
Originally posted by Rob Pike:
Hi,
The main browser window is displaying the application I've created. On that window the user can do a city lookup based on keywords. If multiple cities are found a new window is created with all the cities listed as links (i.e. click the link and that city is stored in the city text field). If the user goes back to the main window without closing that window and does another search, the new results are concatenated onto the bottom of the last results in the results window. I realize I can just close the window on blur but I need it kept open so the user can change the city at any point with one of the cities previously found. This new window by the way is not pointing to a specific URL but is created within the body of the script (this is a JSP application). I set up the open like follows :
NewWin = window.open("", "newwin", ".....");
Any suggestions? Thanks in advance.
Rob


SCJP, SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Opening Windows
 
Similar Threads
session question
Pass data back to Window 1 from Window 2
jsf page refresh
Paging search results and multiple browser windows
Javascript help : Please