Comparing with IFrame globals is a nice idea but not sure if it works
in practice. Maybe I'm doing something wrong...

(firefox 3.6 on url 'about:blank')

var frameGlobals = [], myGlobals = [], i=0;
var frame = document.createElement('iframe');
//populate array of frame globals
for (frameGlobals[i++] in frame);
//iterate window props and add "no finds" to myGlobals array
for (var prop in window) {
    ~frameGlobals.indexOf(prop) || myGlobals.push(prop);
}
myGlobals.length //104!!

I expected just 5 (frameGlobals, myGlobals, i, frame and prop). The
others appear to be DOM attributes of window as well as firefox/
firebug properties

On Jan 14, 11:40 am, Diego Perini <[email protected]> wrote:
> On Jan 14, 2:45 am, cancel bubble <[email protected]> wrote:
>
>
>
> > Hello all,
>
> > I'm attempting to build a little utility script I can include in all my dev
> > projects/environment that will report any global variables.  I can then
> > investigate these globals and leave as-is ($ and jQuery for example) or
> > hopefully correct them to not be globals.  The goal is to reduce the number
> > of global variables.  My dev environment is currently Firefox so that's the
> > only browser I'm concerned with this running in (at the moment).  I have an
> > initial script up at:
>
> >http://jsbin.com/oniyi3
>
> > And would love some feedback, particularly in how I'm detecting global
> > vars.  What I came up with doing is:
>
> > Iterate through the global window object to generate a list of all the
> > native global properties in my current version of Firefox.  I did this via
> > the console.log() and just copied/pasted the results into an array.  You'll
> > see this at line 75.  I then basically do the same thing again and compare
> > with this "native_firefox" array.  Any differences would be the user-defined
> > globals, which is what I'm interested in.  I then just output them at the
> > top right of the screen and I've got a list of globals to investigate.
>
> > My concern with the "native_firefox" array is new properties are going to
> > show up with new versions of Firefox so it's a manual maintenance issue,
> > which I'd love to avoid.
>
> > Is there an automated way to get a list of all native global properties?
>
> An IFRAME is the right way to go... Compare global properties of a
> native IFRAME with those of your global scope.
>
> --
> Diego
>
> > Thanks!

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to