Components object
Implements the XPConnect (Cross Platform Connect) technology that provides interaction between XPCOM (Cross Platform Component Object Model) and JavaScript.
XPCOM is similar to Microsoft COM.
Syntax:
Properties that reference the object:
| window.Components |
Possible members:
Properties:
Returns a read-only object through which the registered component classes are accessible by ContractID (contract identifier).
This property is read-only. |
|||||||
Returns a read-only object through which the registered component classes are accessible by ClassID (class identifier).
This property is read-only. |
|||||||
Returns a read-only object through which interfaces are accessible by name.
This property is read-only. |
|||||||
Returns a read-only object through which interfaces are accessible by IID (interface identifier).
This property is read-only. |
|||||||
Returns an integer that represents the result of the most recent XPCOM method call.
This property is read-only. |
|||||||
Returns a reference to the global component manager service.
This property is read/write. |
|||||||
Returns a read-only object through which the known result codes are accessible by name.
This property is read-only. |
|||||||
Returns an integer that represents the result of the current XPCOM method call.
This property is read/write. |
|||||||
Returns an object that represents the current JavaScript call stack.
This property is read-only. |
|||||||
Implements useful features for the XPConnect (Cross Platform Connect) technology. |
Methods:
Constructor (contractID [, interfaceName [, initFuncName]]) |
Creates a function that can be used to create an instance of the specified XPCOM component.
Parameters:
Return value:
Returns a function that can be used to create an instance of the specified XPCOM component.
|
||||||||||||||||||||||||||||||||||||||
Exception ([ message [, result [, stack [, data]]]]) |
Creates an XPCOM exception object that provides more complex error handling in JavaScript.
Use the throw statement to throw an exception in JavaScript.
Parameters:
Return value:
Returns the created XPCOM exception object.
|
||||||||||||||||||||||||||||||||||||||
ID (clsID) |
Creates an object that represents an IID (interface identifier).
Parameters:
Return value:
Returns an object that represents the specified interface identifier.
|
||||||||||||||||||||||||||||||||||||||
isSuccessCode (code) |
Returns a Boolean value that indicates whether the specified XPCOM result code is valid or not.
Parameters:
Return value:
Returns a Boolean value that indicates whether the specified XPCOM result code is valid or not.
|
Example HTML code 1:
This example prints a message to the Error Console. If you need other solutions for dumping messages to console windows in different browsers, please see the page for the dump method.
|
||||
<head> <script type="text/javascript"> if (window.Components) { // UniversalXPConnect privilege is required in Firefox try { if (window.netscape && netscape.security) { // Firefox netscape.security.PrivilegeManager.enablePrivilege ("UniversalXPConnect"); } } catch (e) { alert ("UniversalXPConnect privilege is required for this operation!"); return; } var console = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService); console.logStringMessage("A message for the Error Console."); } else { alert ("Your browser does not support this example!"); } </script> </head> |
||||
|
||||
Did you find this example helpful?
|
External links:
Components object (Mozilla Developer Center)
XPConnect (Mozilla Developer Center)
Components (Wikipedia)
XPConnect (Mozilla Developer Center)
Components (Wikipedia)
User Contributed Comments