间歇性 JavaScript 问题
我正在通过 eval 运行一些 JavaScript(我知道,开枪吧),它基本上枚举了文档对象上的所有属性。我的问题是,虽然它在 firebug 中工作,但从脚本运行时,它在 Firefox 中抛出未实现的异常。
链接到 JavaScript 脚本、引发的异常以及 firebug 命令的工作。
任何建议这是怎么回事?
根据记录,这是在 Ubuntu 10.04 64 位上的 Firefox 3.6.10 上完成的,而 chrome 没有这个问题。
I'm running some JavaScript via eval (I know, shoot me), that basically enumerates all of the properties on the document object. My issue is that while it works in firebug, it throws a not implemented exception in Firefox, when run from a script.
Link to JavaScript script, the exception thrown, and the firebug command working.
Any suggestions as to what's going on here?
For the record, this is done on Firefox 3.6.10 on Ubuntu 10.04 64-bit, and chrome does not have this issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误就在这里:
删除该行,一切都应该没问题。
console
对象是一个 Firebug 对象(指 Firebug 控制台)。 Safari/Chrome 恰好也实现了一个console
对象(指 Webkit js 控制台)。 Firefox,实际上其他浏览器没有控制台对象。所以它会抛出一个错误。顺便说一句:像往常一样,评估是完全没有必要的。这是完全等效的代码:
如果您坚持将其称为
request
,则将其用作引用:字符串传递对象名称,那么为了理智起见,请以一种不太令人困惑的方式使用 eval:
如果您坚持通过 我什至不会这样做(有时这是必要的,但只是很少)。
The error is here:
remove that line and all should be fine.
The
console
object is a Firebug thing (refers to the Firebug console). Safari/Chrome just happen to also implement aconsole
object (refers to Webkit js console). Firefox, indeed other browsers don't have a console object. So it throws an error.BTW: As usual, the evals are completely unnecessary. This is exactly equivalent code:
If you insist on calling it
request
then use it as a reference:If you insist on passing object names by string, then for sanity's sake use eval in a less confusing way:
Though I wouldn't do even that (sometimes it is necessary, but only very rarely).