Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question test if window object still valid before using

    In my site design some links are opened in a re-used (i.e. named) window. Because some of the pages opened there rename the window (e.g. by explicitly setting self.name="other_name"), I "loose" access to that window for the next such link being followed.

    To work around this, I rememer the window object when it's first opened and "push" my window name back into it. I use setTimeout() to setup this "name push" several times over the subsequent few seconds - but this creates a new problem: if the window is closed (X'ed out, not just minimized) then my push function generates an error because the window no longer exists when the code attempts mywin.name = "my_name".

    Specifically, I this gives me an error: The callee (server [not server application]) is not available and disappeared; all connections are invalid. The call did not execute.

    SO! Is there a way to test that a window object still refers to an available window before using it?


    TIA!

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    x = window.open('.........

    if (x && !x.closed) {....

    Something odd about your re-naming 'push' but, whatever works...

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Cheese: I believe the post was about named windows, not window objects stored in a variable. The kind of window name you use in the target attribute, in the frames collection, in the second argument of the window.open method etc.

    Slintz: You should be able to check for oWindowReference.closed. If it's true, then the window is no longer open and you need to open it again. That can be managed by an onclick on the link, for example.
    Last edited by liorean; 06-02-2003 at 01:07 AM.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile both are right!

    Thanks, cheesebagpipe - testing winobj.open() does the trick!

    Also, liorean is correct that the kind of window I am using is the kind "you use in the target attribute."


    TAGAT


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •