Hello -
Is there a way to access global variables, whose names are not already known, including globally defined function names?
Using the for/in technique on the global window object doesn't seem to work as expected as the global x variable is never shown in this loop:
var x = "xVar";
function showGlobalProperties() {
for(var prop in window) alert("Property " +prop);
}
HOWEVER -
alert(window.x);
OR
alert(window["x"] );
works fine, as expected.
For/in seems to work fine on objects that I've created.
- unclear though why it doesn't seem to work with predefined objects. BTW, my test platform is IE6 on Win2k. Thanks for your thoughts!
- Hnorris
Is there a way to access global variables, whose names are not already known, including globally defined function names?
Using the for/in technique on the global window object doesn't seem to work as expected as the global x variable is never shown in this loop:
var x = "xVar";
function showGlobalProperties() {
for(var prop in window) alert("Property " +prop);
}
HOWEVER -
alert(window.x);
OR
alert(window["x"] );
works fine, as expected.
For/in seems to work fine on objects that I've created.
- unclear though why it doesn't seem to work with predefined objects. BTW, my test platform is IE6 on Win2k. Thanks for your thoughts!
- Hnorris