JavaScript:Ci 未定义

发布于 2024-07-08 03:59:56 字数 596 浏览 7 评论 0原文

我刚刚花了半个小时来找出导致我的 JavaScript 代码中出现错误消息“Ci 未定义”的原因。 我终于找到了原因:

它应该是(jQuery):

$("asd").bla();

它是:(

("asd").bla();

美元符号消失了)

现在解决了问题后,我想了解消息本身:当Firefox告诉我“Ci”时,它是什么意思没有定义。 什么是“慈”?


更新: 我正在使用当前版本的 Firefox (3.0.3)。

要重现,只需使用以下 HTML 代码:

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

为了明确起见:我知道是什么导致了错误消息。 我只是想知道 Firefox 试图通过“Ci”告诉我什么......

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"...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

神仙妹妹 2024-07-15 03:59:56

我不知道您使用的是哪个版本的 FF,但无论如何,该消息可能指的是 bla() 不是 String 对象上可用的函数。 由于您缺少 $,这意味着您缺少一个函数,("asd") 将计算为字符串,然后 JavaScript 解释器将尝试调用 <该对象上的 code>bla() 。 因此,如果您的项目中有以下代码:

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

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

那么,Ci 可能是一些内部 Firefox 符号,仅指代函数的概念。 这是我的猜测,我想您需要了解 Firefox 内部结构的人才能更好地回答这个问题...


更新:我正在完全相同相同的版本中运行您的示例代码FF 和你一样,但它报告错误为:

错误:“asd”.bla 不是函数
源文件:file:///C:/test.html
行:3

也许您正在运行一个扩展/插件来执行此操作? 也许有一些 Greasemonkey 脚本之类的?

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?

墨落成白 2024-07-15 03:59:56

杰森似乎是对的。 许多插件(例如 Firebug、Geode)使用 Ci 作为快捷方式:

const Ci = Components.interfaces; 

因此这些插件似乎会导致奇怪的错误消息。

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.

南汐寒笙箫 2024-07-15 03:59:56

假设是CodeIngiter,它找不到js文件。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文