views:

721

answers:

3

I just spent half an one our to find out what caused the Error-Message "Ci is not defined" in my JavaScript code. I finally found the reason:

It should be (jQuery):

$("asd").bla();

It was:

("asd").bla();

(Dollar sign gone missing)

Now after having fixed the problem I'd like to understand the message itself: What does Firefox mean when it tells me that "Ci" is not defined. What's "Ci"?


Update: I'm using the current version of Firefox (3.0.3).

To reproduce, just use this HTML code:

<html><head><title>test</title>
<script>
("asd").bla();
</script>
</head><body></body></html>

To make it clear: I know what caused the error message. I'd just like to know what Firefox tries to tell me with "Ci"...

A: 

Assuming it's CodeIngiter, it can't find the js file.

Diodeus
I'm not using CodeIgniter.
BlaM
+3  A: 

I don't know which version of FF you are using, but regardless, the message is probably referring to the fact that bla() is not a function available on the String object. Since you were missing the $, which means you were missing a function, ("asd") would evaluate to a string, and then the JavaScript interpreter would try to call bla() on that object. So, if you had the following code in your project:

String.prototype.bla = function() {};

// now this next line will execute without any problems:
("asd").bla();

So, it is possible that Ci is some internal Firefox symbol that simply refers to the idea of a function. That is my guess, I imagine you are going to need someone that knows something about Firefox's internals to get a better answer to this question...


UPDATE: I am running your example code in the exact same version of FF as you are, but it reports the error as:

Error: "asd".bla is not a function
Source File: file:///C:/test.html
Line: 3

Perhaps you have an extension/plug-in running that does something with this? Maybe some Greasemonkey script or something?

Jason Bunting
Plugin: Might be... Greasemonkey: It shouldn't do anything on that host... But who knows... ;)
BlaM
You seem to be right. Ci is used in quite a lot of plugins as a shortcut to "Components.interfaces".
BlaM
+2  A: 

Jason seems to be right. Many plugins (e.g. Firebug, Geode) use Ci as a shortcut:

const Ci = Components.interfaces;

So the plugins seem to cause that strange error message.

BlaM