Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Components.classes is undefined?

In Firefox when I am running the following code:

var clazz = Components.classes["@mozilla.org/messenger;1"];

This error is coming:

TypeError: Components.classes is undefined

Please see this link: http://jsfiddle.net/BbrvX/

For information about Components.classes visit the following link:

https://developer.mozilla.org/en/docs/Components.classes

like image 257
Sanjeev Avatar asked Feb 13 '23 23:02

Sanjeev


2 Answers

Components.classes is for chrome code, extensions or browser development. You don't have access to it in content pages.

like image 113
Joan Charmant Avatar answered Feb 17 '23 08:02

Joan Charmant


If you are developing your addon using the Addon SDK you should use this idiom:

var { Cc } = require("chrome");
var clazz = Cc["@mozilla.org/messenger;1"];

where Cc stands for Component.classes. You can read more on this here.

like image 42
matagus Avatar answered Feb 17 '23 07:02

matagus