Displaying Javascript Environment, functions and Variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aaron Gray

    Displaying Javascript Environment, functions and Variables

    I want to display all the variables and functions availiable to a web page.
    I used to have a JavaScript that did this but are unable to get it at the
    moment, could someone post such a script please.

    Aaron


  • Martin Honnen

    #2
    Re: Displaying Javascript Environment, functions and Variables



    Aaron Gray wrote:
    [color=blue]
    > I want to display all the variables and functions availiable to a web page.
    > I used to have a JavaScript that did this but are unable to get it at the
    > moment, could someone post such a script please.[/color]

    You can enumerate the properties and methods of an object, for instance
    the window object
    var text = '';
    for (var property in window) {
    text += property + ': ' + (typeof window[property] + '; ';
    }
    alert(text);
    But it depends on the browser whether host methods like resizeTo are
    exposed to the for .. in enuemration.


    --

    Martin Honnen

    Comment

    • Aaron Gray

      #3
      Re: Displaying Javascript Environment, functions and Variables

      > You can enumerate the properties and methods of an object, for instance[color=blue]
      > the window object
      > var text = '';
      > for (var property in window) {
      > text += property + ': ' + (typeof window[property] + '; ';
      > }
      > alert(text);
      > But it depends on the browser whether host methods like resizeTo are
      > exposed to the for .. in enuemration.[/color]

      Thanks, that's a good start,

      Aaron


      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: Displaying Javascript Environment, functions and Variables

        Aaron Gray wrote:
        [color=blue]
        > I want to display all the variables and functions availiable to a web
        > page. I used to have a JavaScript that did this but are unable to get
        > it at the moment, could someone post such a script please.[/color]

        Try <http://pointedears.de/ObjectInspector > (or
        <http://pointedears.ml-webhosting.de/ObjectInspector >).

        But note that since I am using my own script libraries to realize the
        app, many items that are displayed are not built-in but defined in the
        libraries; I have not found a way to workaround that effectively yet,
        suggestions are welcome. Sometimes you can distinguish between built-in
        and library properties anyway since the former are often not enumerable
        and so have the icon for the DontEnum flag displayed, and their value
        contains specific substrings like "[native code]".


        HTH

        PointedEars
        --
        I ate your Web page. Forgive me; it was tasty And tart on my tongue

        Comment

        Working...