Problems Accessing Global Array

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

    Problems Accessing Global Array

    I'm having problems accessing a global array variable from within a
    function. I have something like this:

    ------------------------------------
    var detail = new Array( 20 );
    detail[ 0 ] = "hello";

    function ShowDetail( ) {
    top.frames[2].document.clear ();
    top.frames[2].document.write ("<html><body>" );

    top.frames[2].document.write ( detail[ 0 ] );

    top.frames[2].document.write ("</body></html>");
    top.frames[2].document.close ();
    }
    ------------------------------------

    When I call ShowDetail(), I expect it to write "hello" in the frame, but
    instead it writes "undefined. " What am I doing wrong?

    Thanks,

    Greg.


  • Gregor

    #2
    Re: Problems Accessing Global Array

    Nevermind. I made a stupid mistake, which is actually not in the code I
    posted.


    Gregor <palam_POOP_ede s@softhome.net> wrote in
    news:6G_Ua.5414 61$ro6.12372519 @news2.calgary. shaw.ca:
    [color=blue]
    > I'm having problems accessing a global array variable from within a
    > function. I have something like this:
    >
    > ------------------------------------
    > var detail = new Array( 20 );
    > detail[ 0 ] = "hello";
    >
    > function ShowDetail( ) {
    > top.frames[2].document.clear ();
    > top.frames[2].document.write ("<html><body>" );
    >
    > top.frames[2].document.write ( detail[ 0 ] );
    >
    > top.frames[2].document.write ("</body></html>");
    > top.frames[2].document.close ();
    > }
    > ------------------------------------
    >
    > When I call ShowDetail(), I expect it to write "hello" in the frame,
    > but instead it writes "undefined. " What am I doing wrong?
    >
    > Thanks,
    >
    > Greg.
    >
    >
    >[/color]

    Comment

    Working...