[Project_owners] Call js function from xpcom

Dmitry Belous dmitry_belous at ua.fm
Wed Jul 16 18:07:25 EDT 2003


Hi, All

I write xpcom component. Message of error logged into
javascript console. But I want to call callback function
that user-written on javascript.

For example:

  <script language="javascript">
    function myerrorhandle(errmsg)
    {
      document.write("error: " + errmsg);
    }
    function mywarninghandle(wrnmsg)
    {
      document.write("warning: " + wrnmsg);
    }
    function validator(xs, xml)
    {
      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
      var TCOMlibxml = new Components.Constructor("@mozilla.org/comlibxml/libxml;1", "nsICOMlibxml");
      var libxml = new TCOMlibxml();
>     libxml.xmlSchemaSetParserError(myerrorhandle, mywarninghandle);
      var xsdoc = libxml.xmlSchemaParseMemory(xs, xs.length);
      var xmldoc = libxml.xmlParseMemory(xml, xml.length);
      var res = libxml.xmlSchemaValidateDoc(xsdoc, xmldoc);
      return res;
    }
</script>

How can I call javascript function from xpcom component
implementation on C++?

-- 
 Regads,
 Dmitry                          mailto:dmitry_belous at ua.fm



More information about the Project_owners mailing list