Here's some vowels for you in case you are running low:
aaaaaaaaaaaaaeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiiiioooo oooooooooouuuuuuuuuuuuu
When you declare a variable either outside of a function or without using the var keyword, it becomes a property of the window object, and any script can access it (since 'with window' is assumed).
In other words:
-
<script type="text/javascript">
-
var g_One = 'I am global because my context is window.';
-
g_Two = 'I am also global.';
-
window.g_Three = 'Also global.';
-
window['g_Four'] = 'Yup. Global.';
-
this.g_Five = 'Probably global, but not reliable, since {this} might not be window.';
-
-
function doSomething() {
-
var notGlobal = 'I am *not* global because my context is doSomething, not window.';
-
-
g_Six = 'This is global, because {with window} is assumed.';
-
window.g_Seven = 'Global!';
-
-
this.g_Eight = 'Probably global, but not reliable, since {this} might not be window; it depends on how doSomething gets used.';
-
}
-
</script>
-
Anything defined within an iframe should still be accessible, but window might not be an assumed context. It's been years since I've programmed for iFrames, but if you're sure it's a global, try this:
-
// If this line doesn't work...
-
alert(myVar);
-
// ... try this instead.
-
alert(window.myVar);
-
// Or:
-
alert(window['myVar']);
-
-
// If that doesn't work, check where you define myVar and make sure it's getting attached to the window.
-