I have a script tag with 'A' variable and has been initialised as 16 but when I use alert on IE under onclick event, I received undefine rather than 16.
Is this the problem in IE 6?
e.g.
var A =16;undefine
I have a script tag with 'A' variable and has been initialised as 16 but when I use alert on IE under onclick event, I received undefine rather than 16.
Is this the problem in IE 6?
e.g.
var A =16;undefine
You need to post an example of what you are talking about, but the problem may be in where your script tag is and where you are calling the variable from.
I'd bet on it being caused by some slight confusion...
Being that putting var in front of a variable puts that variable into the local scope only in Javascript, and a variable delcaration without it (a = 16) is global.
function test() {
a = 16;
var b = 16;
}
test();
alert(a); # alerts 16
alert(b); # throws error, b is undefined