Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Lolu chungechunge lwabekwa kunqolobane. Uyacelwa ubuze umbuzo omusha uma udinga usizo.

TypeError: Components.classes is undefined

  • 1 baphendule
  • 11 zinale nkinga
  • Igcine ukuphendulwa ngu jscher2000

more options

I saw many questions like "Components.classes[xyz]" is undefined, but I have an issue with the Components.classes object itself being undefined. I have a small dummy html page where I'm trying to run a basic sample script from (slightly altered):

<script type="text/javascript"> function blah() { var c = Components; var clazzes = c.classes; // clazzes is still undefined after this line executes var myClass = clazzes[";1"]; // here it throws var bmks = myClass.getService(Components.interfaces.nsIBookmarksService); // call one of the object's methods: // flush the bookmarks to disk if they've been touched. bmks.Flush( ); } </script>

I've already tried running Firefox in safe mode, and it's a fresh installation of the application. Am I missing some sort of initialization?

All Replies (1)

more options

Generally speaking, web pages cannot access the privileged parts of Firefox such as preferences and bookmarks. There is an exception for digitally signed scripts in some cases, but during development and testing, of course, that's impractical due to frequent code changes.

If you are working on creating an add-on, consider using the Add-on SDK. More info: