javascript - Firefox 中的 console.dir(window)?

标签 javascript firefox google-chrome browser firebug

console.dir(window) 在 Chrome 中:

http://ecmazing.com/unsorted/console-dir-window-in-chrome.png

console.dir(window) 在 Firebug 中(在 Firefox 7 中):

http://ecmazing.com/unsorted/console-dir-window-in-firebug.png

为什么 Firebug 只列出 window 对象的几个属性?如何列出 Firefox 中的所有全局属性?

此外,__proto__ 属性在哪里,以便我可以跟踪原型(prototype)链?

最佳答案

看起来 Firebug 正在过滤掉不满足 hasOwnProperty 的属性。例如,当使用 Firefox 4/Firebug 1.7 投资 DOM 时,navigatoraddHandler 出现,但 confirm 没有出现。观察:

>>> window.hasOwnProperty('confirm')
false
>>> window.hasOwnProperty('addHandler')
true
>>> window.hasOwnProperty('navigator')
true

但是,Date 没有显示,并且:

>>> window.hasOwnProperty('Date')
true

所以它似乎也在过滤掉全局构造函数,这似乎被 comment 9 证实了在 this bug .我不知道使用什么函数来过滤掉这些构造函数。

不管怎样,我还没有找到解决这个问题的方法。如果我这样做了,我会通知你,但我认为在撰写本文时,没有办法做你想做的事。

关于javascript - Firefox 中的 console.dir(window)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5412176/

相关文章:

javascript - 在 switch/case 中使用 return 后还需要使用 break 吗?

javascript - 页面加载且脚本运行错误时不显示内容

python - WebDriverException : Message: Service C:\Program Files\Mozilla Firefox\firefox. exe 通过 Selenium 使用 DesiredCapativity 意外退出

javascript - 在 chrome.storage 中存储复杂对象

javascript - 具有复杂 json 的 CORS 兼容 $.ajax 后调用

javascript - 在 ORM 中实现(继承)Promise 接口(interface)

css - 将时尚应用于所有网站,但不适用于浏览器

html - 记住密码在 ff 中有效,但在 ie 和 chrome 中无效

html - 使用wordpress加载文档的长时间延迟

google-chrome - 谷歌网络字体根本不显示 - chrome 最新版本,mac