P
Patient Guy
I have a library of functions representing a filesystem interface
(essentially a file selection interface, to be used in
opening/reading/writing/closing files).
Heavily scripted HTML document #1, very application-like, must include the
JS file for this library of functions. One reason is that it must call a
function to name a "callback" function, and within its own script block,
must define the callback function. The callback handles the selected file
name.
HTML document #2 is essentially a new document (window) created to present
the filesystem/file selection interface as dynamically updated HTML-
formatted tables of the list of file names/properties and subdirectory
names/properties of the current directory.
The problem is that the JS library file includes global variables which
are arrays to store the current directory file and subdirectory info. The
JS file is included through a <SCRIPT> element (as external JS file) in
both HTML documents #1 and #2. Document #2 is created through an open()
window call in Document #1.
The odd thing is: Document #2 creates the arrays in the defined global
variables, and then the array variables are accessed to build the HTML-
formatted tables during the initial creation of Document #2.
But when the user presses a button inside Document #2 to select a file or
folder in a table cell, the arrays are "undefined" ("void").
I am seeing this as a some sort of conflict of global variables between
documents #1 and #2. That is global variables in Document #1 (the parent
window/document) could be used to construct document #2, and then when
document #2 was intially constructed, its inherited global variables were
initialized (undefined globals are "voided").
I have been trying to find something in the JS/ECMA specification which
explains how this works and how to deal with this.
(essentially a file selection interface, to be used in
opening/reading/writing/closing files).
Heavily scripted HTML document #1, very application-like, must include the
JS file for this library of functions. One reason is that it must call a
function to name a "callback" function, and within its own script block,
must define the callback function. The callback handles the selected file
name.
HTML document #2 is essentially a new document (window) created to present
the filesystem/file selection interface as dynamically updated HTML-
formatted tables of the list of file names/properties and subdirectory
names/properties of the current directory.
The problem is that the JS library file includes global variables which
are arrays to store the current directory file and subdirectory info. The
JS file is included through a <SCRIPT> element (as external JS file) in
both HTML documents #1 and #2. Document #2 is created through an open()
window call in Document #1.
The odd thing is: Document #2 creates the arrays in the defined global
variables, and then the array variables are accessed to build the HTML-
formatted tables during the initial creation of Document #2.
But when the user presses a button inside Document #2 to select a file or
folder in a table cell, the arrays are "undefined" ("void").
I am seeing this as a some sort of conflict of global variables between
documents #1 and #2. That is global variables in Document #1 (the parent
window/document) could be used to construct document #2, and then when
document #2 was intially constructed, its inherited global variables were
initialized (undefined globals are "voided").
I have been trying to find something in the JS/ECMA specification which
explains how this works and how to deal with this.