Yel wrote:
> On Oct 30, 12:44 pm, John J Barton <[email protected]>
> wrote:
>   
>> I guess I don't understand. Just use for-in loop over "window"
>> properties?
>> You must have something else in mind.
>> jjb
>>     
>
> Yeah, for-in loop over "window" does work in Firefox, although I
> cannot make sure
> if firebug really works in this way.
> BTW: for-in loop cannot list global variables in IE6/7/8 except they
> are declared like
> "window.gVar = xxx". I guess that's why IE Developer Toolbar cannot
> tell global
> variables or debug it.
Hmm... That's interesting. In all browsers below code will give you 
alert with 123:
javascript:var xxx = 123;alert(window.xxx)

But output of below function is browser's engine dependant:
var xxx = 123
function test()
{
    var out = document.getElementsByTagName('textarea')[0]
    for (var obj in window)
    {
        if (typeof(window[obj])!='function')
            out.value+='\nwindow.'+obj +' => ('+typeof(window[obj])+') 
'+ window[obj];
    }
}

In FF it will show you quite a lot of stuff and your global variables.
In Chrome you will get even more as some "null" variables will be shown 
(like window.on*).
In IE you will get pretty much the same as in Chrome, but without global 
variables.
And in Opera... Well I was kinda shocked, because the output was 
"window.opera => (object) [object Opera]" :-)). Then I noticed some of 
stuff linked to window object in Opera doesn't have toString methods so 
you'll have use something like:
{out.value+='\nwindow.'+obj +' => ('+typeof(window[obj])+') '+ 
window[obj];}catch (e){}
And then it will work in Opera too and it will show you global vars.

And as you said before setting window.xxx rather then var xxx will make 
it work for IE too. Still watching the variable xxx in IE's dev tool 
_is_ possible in both situations. The only drawback is that you won't 
see your watch if you're not debugging (simply switching to debugging 
won't work - you'll have to break on some point).

Regards,
Nux.

--

You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/firebug?hl=en.


Reply via email to