[Project_owners] HTTP Auth's opening URL

Michael Vincent mv_van_rantwijk at yahoo.com
Fri Oct 7 00:44:33 EDT 2005


Eric Jung wrote:
> Here's what I tried in order to get that text in the dialog:
> 
> // listen for popups
> var watcher = Components.
>   classes["@mozilla.org/embedcomp/window-watcher;1"].
>   createInstance(Components.interfaces.nsIWindowWatcher);
> watcher.registerNotification(this);
> 
> ...
> 
> observe : function(domWindow, topic, data) {
>   if (topic == "domwindowopened")
>     // Wait for the XUL to load
>     domWindow.addEventListener("load", this.onNewWnd, true);
> },
> 
> onNewWnd : function() {
>   var wm = Components.
>     classes["@mozilla.org/appshell/window-mediator;1"].
>     getService(Components.interfaces.nsIWindowMediator);
>   var recentWindow = wm.getMostRecentWindow(null);
>   // dump contents of that string
>   if (recentWindow)
>     dump(recentWindow.document.getElementById("info.box:") + "\n");
> }
> 
> This dumps null. I've also tried:
> 
> onNewWnd : function() {
>   var watcher = Components.
>     classes["@mozilla.org/embedcomp/window-watcher;1"].
>     createInstance(Components.interfaces.nsIWindowWatcher);
>   var e = watcher.getWindowEnumerator();
>   while (e.hasMoreElements()) {
>     var w = e.getNext().
>       QueryInterface(Components.interfaces.nsIDOMWindow);
>       dump(w.name + "\n");
>   }
> }
> 
> No luck there, and also with many variations on both of these...I
> think I'm close, but I just don't know how to get the "info.box"
> text...

Take a look at the code:

   // display the main text
   var messageText = gCommonDialogParam.GetString(0);
   var messageParent = document.getElementById("info.box");
   var messageParagraphs = messageText.split("\n");

   for (var i = 0; i < messageParagraphs.length; i++) {
     var descriptionNode = document.createElement("description");
     var text = document.createTextNode(messageParagraphs[i]);
     descriptionNode.appendChild(text);
     messageParent.appendChild(descriptionNode);
   }

and note that they add <description> elements, so you need to use the 
.textContent property.

Michael


More information about the Project_owners mailing list