Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3846184
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:21:32+00:00 2026-05-19T16:21:32+00:00

How to check if a given window is open in Xul? I would like

  • 0

How to check if a given window is open in Xul?

I would like to check if a window is already openned in my desktop app. So if it is, I’ll not open it again.

— my attempt

I’m trying to accomplish this using the window title, so I get the list of windows from windowManager and check the title, but the getAttribute is not from an interface that I can query, it’s from element, what interface should I use?

var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);
var enum = windowManager.getXULWindowEnumerator(null);
while(enum.hasMoreElements()) {
    var win = enum.getNext().QueryInterface(Components.interfaces[" WHICH INTERFACE TO PUT HERE? "]);
    write("WINDOW TITLE = " + win.getAttribute("title"));
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:21:33+00:00Added an answer on May 19, 2026 at 4:21 pm
    var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);
    var enum = windowManager.getEnumerator(null);
    while(enum.hasMoreElements()) {
      var win = enum.getNext().QueryInterface( Components.interfaces.nsIDOMChromeWindow );
      write("WINDOW TITLE = " + win.document.documentElement.getAttribute("title") );
    }
    

    if you are using getXULWindowEnumerator you should use Components.interfaces.nsIXULWindow

    you probably could use the nsIDOMWindow attribute name if you open the windows your self because you set the name of the window in the open function. This is not visible to the user so you have a little more flexibility

    var win = window.open( "chrome://myextension/content/about.xul", 
                              "windowName", "chrome,centerscreen" );
    
    write( "WINDOW NAME: " + win.name ); // Should now give  WINDOW NAME: windowName
    

    If you are leaving the window name blank it will open a new window every time. If you however use a window name (something else than “” ) it will create it if it does not exists, or load the new content in the already existing window with the name you have specified.

    Which seems like almost what you want. Butt you could use name attribute to avoid the reload if you have to.

    var openNewWindow = true;
    var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);
    var enum = windowManager.getEnumerator(null);
    
    while(enum.hasMoreElements()) {
      var win = enum.getNext().QueryInterface( Components.interfaces.nsIDOMChromeWindow );
      if( win.name == "windowName" ) {
        openNewWindow = false;
      }
    }
    
    if( openNewWindow ) {
      var win = window.open( "chrome://myextension/content/about.xul", 
                          "windowName", "chrome" );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I check the given email id is valid or not using ELIPS
More specifically, I'm trying to check if given string (a sentence) is in Turkish.
How can I check if a given number is even or odd in C?
I want to check if a given date is more than a month earlier
How do I check if a given object is nullable in other words how
I need to check whether a given date is in the preceding month for
Is there any way to check if a given index of an array exists?
What is the best way to check if a given url points to a
Question: Is there a way to check if a given font is one of
Is there a built-in function/method that can check if a given string is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.