• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to not open a named regular window if it already exisits

 
Farouk Sherefudheen
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All
How can you check If the window with name YWINDOW was already opened by the user
If he tries to click on the link on different page

X page link opens url Y with window name as YWINDOW.

Please help
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this what you are asking for?



Eric
 
Farouk Sherefudheen
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Eric
Thanks for your code. But in our application we have we a main window from App A which would open a link to a new windown in appB , App A and App B are independent application afterr it has been opened.

Your code if i understand right has a instance variable called winPop and then if a window is opened it will be assigned true so when next time someone trries to click on the link to open a window it would fail saying it is already open.

But this will not help in my scenario when if the app B window is closed by that application or by user of browserr for app b. The instance variable in my application will always think there is App B window is always open. SO how can i handle this scenario like when App B is prresent use it otherwise open a new window.


Thanks for your help
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when b is closed, the object is destroyed and it will open up a new window.

Eric
 
Farouk Sherefudheen
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Eric
Thanks, The code works perfect till from application A i stay on the same page and try to invoke the link to app B.

If I move away frm that page in App A the variable is initiased to false and the next time when u click on the link coming back to the page which has the lnk it tries to open window again

what can i do?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You loose the object. JavaScript gets reset when you change pages since it has nothing like session. Ways around it are ugly and deal with frames.

Eric
 
Farouk Sherefudheen
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Eric
Thanks for your rreply. I understand that if you move away from the page which originally created the opened window you loose the new window object refrence (winpop = false) again.

So i am thinking of a way to maintain it even if i move away from the page and I think of 2 ways
1. Using cookies. Write a javascript to write a cookie and store the reference when i open a new window and when i move away frorm the page i initialize the value of winPop by getting the value from cookie.
2. using netscape.javascript.JSObject, please tell me whether it is possible at all.
Would appreciate your expert comments on this.

Farouk
 
Farouk Sherefudheen
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric
Can you please help me on this...
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is critical you are going to have to use a hidden frame and open the windows from that hidden frame.

The cookie would make it a string and not an object.

Eric
 
Farouk Sherefudheen
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thanks
So cookie option is out is it?
Next what about using netscape.javascript.JSObject and storing in session as areference is it possible?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
netscape.javascript.JSObject

When I see something like that I hear not cross browser compliant...You could always try...

Eric
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic