IE Can't Enumerate User-Added Window Properties with for..in

G

gyrm

I'm trying to write a simple javascript profiler that works in IE and
other browsers. In order to get a list of functions to decorate with
profiling code, I intended to enumerate the properties of the window
object, figuring that any functions defined by the user in the global
scope would show up. This works in Firefox ... but doesn't in IE
(argh!). It appears that user-defined functions, when declared in the
typical way, are not enumerable using for..in . (Why is this? Has this
been / Is this going to be fixed?) Other posts seem to corroborate
this ... see references below.

I'm wondering if anyone can think of another way to enumerate global
functions in IE, using the window object or otherwise. What just
occurred to me was parsing <script> tags for strings that seem like
they might be function names, and just trying them against the window
object. This seems like a junky workaround and I'd appreciate other
suggestions if you have them!

Thanks!

Haw-Bin Chai

References:

http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/0389b4dd213bc2a0
http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/a0f3ffdff1869ded
http://developer.mozilla.org/en/docs/ECMAScript_DontEnum_attribute
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top