Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Please help with enumerating functions in window object

Reply
Thread Tools

Please help with enumerating functions in window object

 
 
intrader
Guest
Posts: n/a
 
      01-10-2010
I have a need to enumerate all functions in window object in order to
install intercepts. I have problem with the enumeration using the code
in the example
http://jsbin.com/acubo
Note: for now the code lists all elements in the window object.
I expect to see the global function 'fun' listed but I don't see it.
Why?
 
Reply With Quote
 
 
 
 
Garrett Smith
Guest
Posts: n/a
 
      01-10-2010
intrader wrote:
> I have a need to enumerate all functions in window object in order to
> install intercepts. I have problem with the enumeration using the code
> in the example
> http://jsbin.com/acubo
> Note: for now the code lists all elements in the window object.
> I expect to see the global function 'fun' listed but I don't see it.
> Why?

It is a bug of Internet Explorer. Your global property `fun`, declared as:

var fun = function(){
alert('...');
}

should be enumerable. In IE it is not. In IE, the global object is a
Host object. IE also uses a separate Variable object for the global
Variable object. The global Variable object is specified to be the same
as the global object.

That question, and problems related to the answer, comes up here about
every four months or so, dating back to I think I've seen around 2001 or
so (likely earlier). It is explained well enough here:

http://blogs.msdn.com/ericlippert/ar...-and-this.aspx

A good recent discussion that touched upon this issue, along with other
issues related to IE's global object is [[Delete]]'ing window properties
in IE in JScript.

http://groups.google.com/group/comp....a4dee3390fa71a

And so after you've read all that, the test question:

How do you make `fun` enumerable in IE?

(It's not that hard, really).
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
 
Reply With Quote
 
 
 
 
Jorge
Guest
Posts: n/a
 
      01-10-2010
>
> http://blogs.msdn.com/ericlippert/ar...at-is-the-rela...


(Fabulous euphemism) "Fabulous Adventures In Coding" (...)
"Brendan Eich, the original creator of JavaScript, was kind enough to
point out at great length that I was WRONG WRONG WRONG" (...)
"It is a bug in JScript, or IE. I'm not sure which yet. I will follow
up with the Sustaining Engineering team and see if we can get this
fixed in a future version of IE. However, I wouldn't hold my breath
waiting if I were you." (May 04, 2005)

(Jan 10, 2010) Bug status: NOT FIXED.
--
Jorge.
 
Reply With Quote
 
intrader
Guest
Posts: n/a
 
      01-10-2010
On Jan 10, 1:38*am, Jorge <jo...@jorgechamorro.com> wrote:
> >http://blogs.msdn.com/ericlippert/ar...at-is-the-rela...

>
> (Fabulous euphemism) "Fabulous Adventures In Coding" (...)
> "Brendan Eich, the original creator of JavaScript, was kind enough to
> point out at great length that I was WRONG WRONG WRONG" (...)
> "It is a bug in JScript, or IE. *I'm not sure which yet. I will follow
> up with the Sustaining Engineering team and see if we can get this
> fixed in a future version of IE. However, I wouldn't hold my breath
> waiting if I were you." (May 04, 2005)
>
> (Jan 10, 2010) Bug status: NOT FIXED.
> --
> Jorge.


I appreciate all your answers. The problem remains that I wish to
install intercepts in all functions without modifying the source code;
I am aware that to store the function reference as a property of the
window object ("created_via_property_assignment" as explained by
kangax in http://groups.google.com/group/comp....a4dee3390fa71a)
makes the 'item' enumerable.
The intercepts are for debugging, profiling, and other functions. I am
aware of the Web Developer Tools in IE8 (that provides a profiler).
I apologize for not finding this issue reported before.
 
Reply With Quote
 
Garrett Smith
Guest
Posts: n/a
 
      01-11-2010
kangax wrote:
> On 1/10/10 1:50 PM, intrader wrote:
>> On Jan 10, 1:38 am, Jorge<jo...@jorgechamorro.com> wrote:
>>>> http://blogs.msdn.com/ericlippert/ar...at-is-the-rela...
>>>>

[...]

> Apparently google groups ate part of the title, turning "[[Delete]]'ing"
> into cryptic "]'ing"
>

Maybe Google wants us to read that cryptic "]" as a curse word symbol,
to the effect "effing properites in IE".
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
 
Reply With Quote
 
intrader
Guest
Posts: n/a
 
      01-11-2010
On Jan 10, 8:58*pm, Garrett Smith <dhtmlkitc...@gmail.com> wrote:
> kangax wrote:
> > On 1/10/10 1:50 PM, intrader wrote:
> >> On Jan 10, 1:38 am, Jorge<jo...@jorgechamorro.com> *wrote:
> >>>>http://blogs.msdn.com/ericlippert/ar...at-is-the-rela....

>
> [...]
>
> > Apparently google groups ate part of the title, turning "[[Delete]]'ing"
> > into cryptic "]'ing"

>
> Maybe Google wants us to read that cryptic "]" as a curse word symbol,
> to the effect "effing properites in IE".
> --
> Garrett
> comp.lang.javascript FAQ:http://jibbering.com/faq/


I don't quite follow the delete problem with google.

I don't want to use host access in order to enumerate in IE. However,
the application framework has installed an Active pluggin to help with
caching (not my design), and I think that I can install the intercepts
in the source code.

If you all know of another way to enumerate global functions, I would
appreciate greatly.

Thanks
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
enumerating 'window' for getting the list of global var names in IE sundew Javascript 3 04-07-2006 07:20 PM
Problem enumerating pages in .NET 2.0 Gerry ASP .Net 2 03-26-2006 11:59 PM
Problem enumerating Controls Alejandro Penate-Diaz ASP .Net 1 12-16-2004 10:44 AM
enumerating the files and objects in the .net project Boris Pelmenstein via .NET 247 ASP .Net 1 07-05-2004 04:17 PM
please help me in distinguish redefining functions, overloading functions and overriding functions. Xiangliang Meng C++ 1 06-21-2004 03:11 AM



Advertisments