...

View Full Version : Look at all global values?



jskaar
06-02-2006, 10: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, 10:56 AM
nope.

jskaar
06-02-2006, 11:04 AM
Ok, thanks!

(Living up to your signature:))

jbot
06-02-2006, 11:52 AM
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, 08: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, 04:00 PM
Thanks!

Made an pretty ugly output, but though:)

liorean
06-06-2006, 04: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.)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum