PDA

View Full Version : Look at all global values?



jskaar
06-02-2006, 11:31 AM
Is there any way to look at all global values made from a javascript, without knowing the name of the variables.

jbot
06-02-2006, 11:56 AM
nope.

jskaar
06-02-2006, 12:04 PM
Ok, thanks!

(Living up to your signature:))

jbot
06-02-2006, 12:52 PM
I was just thinking an maybe you could loop through the Window object. That might give you a run down of what's there:



for i in window
{
sMsg+=i+"\n";
}

alert(sMsg)


of course, this is untested, so I may be barking up the wrong tree. one thing it won't do is differeniate variable you declare and those that are part of the DOM.

Kravvitz
06-02-2006, 09:25 PM
I don't think it will work without the parentheses.

var sMsg = '';
for(i in window)
{
sMsg+=i+"\n";
}
alert(sMsg);

jskaar
06-06-2006, 05:00 PM
Thanks!

Made an pretty ugly output, but though:)

liorean
06-06-2006, 05:04 PM
Just be careful when you use that. Iew in particular has a tendency to break down if you try to access some host objects you can find on the window object. (And elsewhere.)