Javascript 的调试策略“TypeError: elem.dispatchEvent is not a func
Debug strategy for Javascript "TypeError: elem.dispatchEvent is not a function" error
在Mac OSX上使用jQuery 2.0.3和Firefox 24上的filedrop HTML5上传器脚本时,我在Firebug中收到此错误。
问题是Firebug报告了一个看似不正确的错误行号 - 它总是报告我的HTML标记的第54行,无论该行上的内容如何 - 我尝试更改它。它从不报告实际上是javascript的行号。
禁用 Firebug 后,脚本似乎可以正常工作。
因此,鉴于此行号没有帮助,我可以使用什么策略来查找此错误的来源?我唯一能想到的就是在我的代码中在 evey 语句之前和之后添加 console.log()
行。有没有更好的方法,或者有没有办法找出这是否是某种观察者效应?
我尝试过:
- 搜索错误,结果大多表明它是一个jQuery与另一个库冲突,但我只使用 jQuery 并尝试过无论如何修复。
- 尝试在代码中的语句中添加日志行,尚无用处但添加更多。
- 相关:"element.dispatchEvent is not a function" js 错误在 FF3.0 的 firebug 中捕获
这是 Firebug 直到版本 1.12.8 中的一个错误,该版本被报告为问题 5939。
这个问题可以通过两种方式解决:
-
安装最新版本的 Firebug
Firebug 2.0 切换到新的 Firefox 调试器 API,修复了旧 API 的许多错误。 -
禁用"脚本"面板
如果出于任何原因无法或不想安装较新版本的 Firebug,则可以暂时禁用"脚本"面板,然后重现错误。然后应报告正确的行号。
相关文章:
- Is onfling available for html, html5
- jQuery is not loaded
- reactRedux is not defined
- ReferenceError: cordova is not defined @ng-cordova.min.js:7
- Jquery - table.row(tr) is undefined
- contentWindow.document.body is null
- Tomcat websocket is not working
- noty.js is returning undefined
- $routeParams is undefined
- NodeJS Multer is not working
- React, Webpack: bundle.js is not generated
- jQuery is not defined - WordPress footer.php
- 谷歌地图API v3:Initial View is Fine,but Gray Box with No Map if
- imageArray[i] = imageItem is incompatible
- GAPI Is Not Defined
- Angular2 rc1, where is shims_for_IE
- Is (!~index) faster than (index === -1)?
- Mouse Out Orange Div "CurrentHeight" is not applyi
- Is jquery's attr() asynchronous?
- Javascript 的调试策略“TypeError: elem.dispatchEvent is not a func