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
    Jan 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    check if window is open without using window.closed

    Hi,

    i´ve a problem. I want to check whether a (pop-Up)window is open or not. I can't use winname.closed, because if the window was not opend yet or was opend by an other page i get an error (winname.closed is not an object). Is there a way to realy check if a window is open and not only check if the window was closed by the user as "winname.closed" does.

    Marc

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    676
    Thanks
    1
    Thanked 0 Times in 0 Posts
    alp...
    fpmc just a nother® forum member posted this just a wayyy® back...(copied/credited/saved from October 7, 1999 8:28:31 AM) hehehe...


    <Script language="JavaScript">
    function openN(URL,winname,ATTR) {
    if (window.winN && !winN.closed) winN.location = URL;
    else winN = open(URL,winname,ATTR);
    winN.focus();
    }
    </Script>

    Instead of using window.open(), one will use:
    window.openN(URL, "win", "width=400...")

    In the entire page, any links that uses window.openN() will always open in one window.

    Just for SonicT. If you want the window always to have the name "win", then

    <Script language="JavaScript">
    function openN(URL,ATTR) {
    if (window.winN && !winN.closed) winN.location = URL;
    else winN = open(URL,"win",ATTR);
    winN.focus();
    }
    </Script>

    To call it:
    window.openN(URL, Attributes)


    just a goodluck® n' hope it helps ya...:O)))

  • #3
    New to the CF scene
    Join Date
    Jan 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    sorry, thats not what I need. I'll try to explain it.
    I want to build a "file-download-system". In the new window i'm using JavaScript to create a list with every file a user has selected (on my whole page)to download them all together. This is why i can't use window.open() more then one time, because a second window.open() will reload the new window and destroy the whole list. this is why i have to know whether the downloader-window is already open or not.

    Marc

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    var fileListWin = null;
    
    function openFileList(){
        if(fileListWin==null || fileListWin.closed){
            fileListWin = window.open();
        } else {
            fileListWin.focus();
        }
    }
    Last edited by Algorithm; 01-19-2003 at 10:49 PM.


  •  

    Posting Permissions

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