S
sundew
so here is the test case:
<head>
<script type='text/javascript'>
// this function simply returns the number of enumerable
namespaces(objects)
function numNSpaces(){
var num = 0;
for(var i in window)
++num;
return num;
};
// get the number of enumerable elements of the 'window'
var numBefore = numNSpaces();
// load a javascript file dynamically at this point.
// and 'json.js' file trivially contains a single js line: "var json =
{id:0};"
load('json.js');
</script>
<script type='text/javascript'>
// get the number of enumerable elements of thie 'window' after
'json.js' loading
var numAfter = numNSpaces();
// assertion-1
assert(numBefore != numAfter, 'all IE versions will fail on this');
// assertion-2
assert(typeof json == 'object', 'but the newly introduced var is
accessable');
// assertion-3
assert(typeof window.json == 'object', 'access var through
"window.json"');
// assertion-4
assert(typeof window['json'] == 'object', 'access var using
window["json"]');
</script>
</head>
I tested it on Opera7, FF1.5, Netscape6, Konqueror3.5.1 and IE5.0 &
IE6.0.
All browsers passed these assertions, but all IE versions were failed
at the 'assertion-1'.
It seems user defined global vars are not enumerable by 'for(var i in
window)' in IEs.
Is there anybody know how to get the names of all top-level namespaces
in IE?
Any input will be greatly appreciated. Thank you.
<head>
<script type='text/javascript'>
// this function simply returns the number of enumerable
namespaces(objects)
function numNSpaces(){
var num = 0;
for(var i in window)
++num;
return num;
};
// get the number of enumerable elements of the 'window'
var numBefore = numNSpaces();
// load a javascript file dynamically at this point.
// and 'json.js' file trivially contains a single js line: "var json =
{id:0};"
load('json.js');
</script>
<script type='text/javascript'>
// get the number of enumerable elements of thie 'window' after
'json.js' loading
var numAfter = numNSpaces();
// assertion-1
assert(numBefore != numAfter, 'all IE versions will fail on this');
// assertion-2
assert(typeof json == 'object', 'but the newly introduced var is
accessable');
// assertion-3
assert(typeof window.json == 'object', 'access var through
"window.json"');
// assertion-4
assert(typeof window['json'] == 'object', 'access var using
window["json"]');
</script>
</head>
I tested it on Opera7, FF1.5, Netscape6, Konqueror3.5.1 and IE5.0 &
IE6.0.
All browsers passed these assertions, but all IE versions were failed
at the 'assertion-1'.
It seems user defined global vars are not enumerable by 'for(var i in
window)' in IEs.
Is there anybody know how to get the names of all top-level namespaces
in IE?
Any input will be greatly appreciated. Thank you.