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 2 of 2
  1. #1
    wac
    wac is offline
    Regular Coder wac's Avatar
    Join Date
    Sep 2002
    Location
    Cary, North Carolina, USA
    Posts
    359
    Thanks
    2
    Thanked 0 Times in 0 Posts

    close a window knowing only its name

    How does one close a window in javascript if all you know is the name of the window?
    Wayne Christian

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    477
    Thanks
    0
    Thanked 51 Times in 50 Posts
    If you know the name of the window (as set in a window.open() command or with window.name='something'), but do not have a pointer to the window itself, you can recreate the pointer by re-opening the window, then close it with the new pointer. The downside to this approach is that if the window is not open in the first place, a new window will be opened and immediately closed.

    var w = window.open('',windowName);
    w.close();


  •  

    Posting Permissions

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