D
dnn
How can I access dynamically loaded variables?
I am trying to load an external javascript file dynamically and then
access its variables. The script is loaded by the onload handler.
The code looks like this:
var constants = document.createElement("script");
constants.src = REL_PATH + "extensions_demo/js/constants_" +
MY_LANGUAGE + ".js";
constants.type ="text/javascript";
document.getElementsByTagName("head")[0].appendChild(constants);
alert(window.ROOM_01); // ROOM_01 is a variable out of the external
file
However alert(window.ROOM_01) returns 'undefined'. How can the
variables of the dynamically loaded file be accessed?
Thanx for helping.
Cheers,
Nico
I am trying to load an external javascript file dynamically and then
access its variables. The script is loaded by the onload handler.
The code looks like this:
var constants = document.createElement("script");
constants.src = REL_PATH + "extensions_demo/js/constants_" +
MY_LANGUAGE + ".js";
constants.type ="text/javascript";
document.getElementsByTagName("head")[0].appendChild(constants);
alert(window.ROOM_01); // ROOM_01 is a variable out of the external
file
However alert(window.ROOM_01) returns 'undefined'. How can the
variables of the dynamically loaded file be accessed?
Thanx for helping.
Cheers,
Nico