[Project_owners] Getting the URL of the current window without using window.location.href

Alex Eng ateng at users.sourceforge.net
Sat Jan 28 19:45:08 EST 2006


Currently, the code inside a JavaScript object which I implemented for a 
Firefox extension retrieves the "chrome:" URL of the current chrome 
window using the "window.location.href" property.

However, I want to move that code into an JavaScript XPCOM object (FYI, 
to eliminate duplication in initialization of the RDF datasources in 
several UI locations in my extension; this XPCOM object would be a 
singleton object and will therefore be instantiated using getService). 
And from what I've researched, the "window" object will not be 
accessible in the context of a XPCOM object.

I've done some reading into nsIWindowMediator, and while it can be used 
to find out if a particular window exists, there doesn't seem to be a 
way to find out from that XPCOM service if the current window from which 
it is invoked from has a given "chrome:" URL.  Unless there is something 
that I missed.

Any pointers and suggestions are appreciated.


More information about the Project_owners mailing list