Problems Accessing Global Array

Giganews Newsgroups
Subject: Problems Accessing Global Array
Posted by:  Gregor (palam_POOP_ed…@softhome.net)
Date: Mon, 28 Jul 2003

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.

Replies