Hi, guys,

Need you help.
I put this cookie.xul in d:/program files/mozilla 
firefox/chrome/cookie/content.
I also add "content,install,url,resource:/chrome/cookie/content/" in 
/chrome/installed-chrome.txt.
When I click the toolbar box or menubox, I've always got exception caused by 
Components.classes call.
Is there anything wrong? Did I miss anything?


Here is the xul code.

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<!DOCTYPE window>
<window 
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";>

<script>

function getCookies()
{
 try{
 alert("here");
  var menu = document.getElementById("cookieMenu");
  menu.removeAllItems();
 alert("before classes");
  var cookieManager = Components.classes["@mozilla.org/cookiemanager;1"]
                        .getService(Components.interfaces.nsICookieManager);
 alert(cookieManager);
  var iter = cookieManager.enumerator;
  while (iter.hasMoreElements()){
    var cookie = iter.getNext();
    if (cookie instanceof Components.interfaces.nsICookie){
      if (cookie.host == "www.mozillazine.org")
        menu.appendItem(cookie.name,cookie.value);
    }
  }
  }
  catch(e)
  {
   alert("exception");
  }
}

function addbm()
{
 try{
    var bms;

    bms = 
Components.classes["@mozilla.org/browser/bookmarks-service;1"].getService(Components.interfaces.nsIBookmarksService);
    bms.addBookmarkImmediately("http://mozilla.org";,
                                      "keeptabs",0,"text/html");
        alert("inside addbm");
        }
        catch(e) {alert("e");}

}

</script>

<hbox>
   <toolbarbutton label="Edit" onclick="addbm()" id="dialog.edit"/>

  <menulist id="cookieMenu" onpopupshowing="getCookies();">
 <menupopup>
    <menuitem label="Car"/>
    <menuitem label="Taxi"/>
    <menuitem label="Bus" selected="true"/>
    <menuitem label="Train"/>
  </menupopup>
  </menulist>
</hbox>
</window> 


_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to