Lee <RE**************@cox.net> wrote in message news:<bm*********@drn.newsguy.com>...
Bill said:
If I declared an array or object in a .JS file, should it not be global
throughout all the files which reference it?
No.
The .js file is just a text file. It doesn't provide any place to
store the data.
As each file loads and interprets the file, each one creates its
own storage space.
I think it's better to think in terms of windows, not files.
Variables are attached to window objects. Loading a window
or frame creates a new window object. The old window
object is gone, along with its variables. In one window,
you can load several .js files and they can refer to one
common set of variables.
Hence a common technique for "global" variables is to use
frames and define the variables in the frameset or frame
that never goes away. Any frame can access the frameset
variables using top.variablename.