javascript - "element.dispatchEvent is not a function"FF3.0的firebug抓到js错误

标签 javascript firebug element dispatchevent

我在 FF3.0 中加载索引页时出现以下错误。抱歉,我无法将脚本粘贴到此处,因为它有 2030 行代码。

element.dispatchEvent is not a function

在展开时它给了我下面的东西,

fire()()prototype.js?1 (line 3972)

_methodized()()prototype.js?1 (line 246)

fireContentLoadedEvent()prototype.js?1 (line 4006)

[Break on this error] element.dispatchEvent(event);

element.dispatchEvent(event); 在 prototype.js 的第 3972 行。我在我的索引页面中包括了 prototype.js 和其他 10 个 js 文件。

有人遇到过这种错误吗?请有人向我解释为什么会出现此错误。

最佳答案

你有没有在同一个页面上使用 jquery 和原型(prototype)?

如果是这样,请使用 jquery noConflict 模式,否则您将覆盖原型(prototype) $ 函数。

通过执行以下操作激活无冲突模式:

<script src="jquery.js"></script>
<script>jQuery.noConflict();</script>

注意:通过这样做,美元符号变量不再代表 jQuery 对象。为了避免重写所有 jQuery 代码,您可以使用这个小技巧为 jQuery 创建一个美元符号范围:

jQuery(function ($) {
    // The dollar sign will equal jQuery in this scope
});

// Out here, the dollar sign still equals Prototype

关于javascript - "element.dispatchEvent is not a function"FF3.0的firebug抓到js错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/980697/

相关文章:

javascript - 将复杂对象从 Angular JS 传递到 Web api 它总是返回 404

javascript - 获取文档中的所有javascript变量

javascript - 如何使用 google developer tools/firebug 记录所有 dom 子树修改

html - 并排显示两个 div 元素的文本溢出

javascript - 将 JSON 传递给 PHP

JavaScript 正则表达式

javascript - 功能不可用 : facebook login is currently unavailable for this app since we are updating additional details for this app. 请重试

javascript - 清除 Firebug 中所有断点的键盘快捷键

JavaScript 数组 - 选择具有偶数值的元素

java - 如何在 Java 中添加/删除数组中的项目?