Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Opening Windows

 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what are you trying to do exactly?
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic