I'm trying to get the url which initiates FF/Mozilla to display the HTTP Basic Authentication dialog (like this). For example, if the user navigates to http://passwordmaker.org:2082, I'd like to get http://passwordmaker.org:2082.
I have this code which seems close, but always gets about:blank. Anyone know what I'm doing wrong?
Code: Select all
var gWindowManager = Components.classes['@mozilla.org/appshell/window-mediator;1']
.getService(Components.interfaces.nsIWindowMediator);
var gWindowManagerListener = {
onOpenWindow: function(aXULWindow) {
var docShell = aXULWindow.docShell;
var requestor = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
var chromeWindow = requestor.getInterface(Components.interfaces.nsIDOMWindow);
var url = chromeWindow.document.location;
dump("url=" + url + "\n");
},
onCloseWindow: function(aXULWindow) {},
onWindowTitleChange: function(aXULWindow, aWindowTitle) {}
};
gWindowManager.addListener(gWindowManagerListener);
Thanks in advance for any help,
grimholtz