RobG wrote:
[Variable assignment in intrinsic script]
or in some function sans 'var' if it needs to be accessible outside
the function:
That makes it global?
Yes.
That's true for Gecko based browsers, but not really for MSIE. Just try
out the following:
<form><p>
<input type="button" name="bar" onclick="foo=1"
value="Execute"foo=1""><br>
<input type="button" onclick="alert(window.foo)"
value="Check global foo property"><br>
</p></form>
As you'll see, when clicking the first, then the second button, in MSIE
"undefined" is alerted. That means, in MSIE, there is no global property
"foo" created. In Geckos, "1" is alerted, so there we have a global
"foo". For cross-browser scripting one should prefer
onclick="var foo=1";
to
onclick="foo=1";
BTW: I didn't find out to which object MSIE adds the foo property here,
but it must be one in both inputs' scope chains in the following example:
<form><p>
<input type="button" name="bar" onclick="foo=1"
value="Execute"foo=1""><br>
<input type="button" onclick="alert(foo)"
value="Execute"alert(foo)""><br>
</p></form>
ciao, dhgm