开发者

console.dir(window) in Firefox?

开发者 https://www.devze.com 2023-02-19 03:04 出处:网络
console.dir(window) in Chrome: http://ecmazing.com/unsorted/console-dir-window-in-chrome.png console.dir(win开发者_高级运维dow) in Firebug (in Firefox 7):

console.dir(window) in Chrome:

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

console.dir(win开发者_高级运维dow) in Firebug (in Firefox 7):

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

Why does Firebug list only a couple of properties of the window object? How can I list all global properties in Firefox?

Also, where is the __proto__ property so that I can follow the prototype chain?


It would seem Firebug is filtering out properties that don't satisfy hasOwnProperty. For example, when investing the DOM using Firefox 4/Firebug 1.7, navigator and addHandler show up, but confirm does not. Observe:

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

However, Date does not show up, and:

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

So it also seems to be filtering out global constructors, which seems to be confirmed by comment 9 on this bug. I do not know what function(s) is/are used for filtering these constructors out.

Either way, I have not found a way to work around this. If I do, I'll let you know, but I think there's just no way to do what you want at the moment of writing.


The vast majority of options seem to be hidden / disabled by default ..

To the right of the letters DOM on the dom tab (while it is selected) of firebug 1.9.0b1 ( and 1.8 im sure..), there is a downward arrow.

Clicking that and selecting all options in the top section (I.E. all apart from "Show Own Properties Only" and "Show Enumerable Properties Only") allowed us to see some otherwise hidden properties.

Im sure the default behaviour used to be to show all properties, and I'm not sure when they changed it but it was pretty frustrating until we found those options.

Hopefully this helps anyone else googling what I just did, trying to figure out why you can get absolutely no useful information out of the DOM Panel of firebug at all.


In FireFox, you can get the full set of window properties with console.log(window); But this will essentially point you to the DOM tab for that object, which shows you the current properties of the object.

Using console.dir(window); instead gives you a snap-shot of the properties of the object at the specific runtime you requested it. If you look you can click the last instance of "window" in your FireFox console.dir(window); result to see the properties tied to the window object at the time of the function call.

0

精彩评论

暂无评论...
验证码 换一张
取 消