Forum Moderators: open
var lmargin, tmargin, winHeight, winWidth, params
This immediately crashes NS4, but works fine in everything else. I thought this was acceptable and a way to save a little bandwidth, but I guess not. If I change it to
var lmargin
var rmargin
It works just fine. It took me so long to figure it out I just had to share!
Tom
On the other hand, assigning a value to an uninitialized variable automatically creates a top-level variable (the nearest thing JavaScript can get to a global variable), so var is redundant outside of a function or control loop body. Even within loops and functions, you can get away without using var, if you know for certain you can keep track of all the variables in all of your scripts on that page.
Once I put one variable per var statement, no problems.
var browser='Navigator 4', javaScriptSupport='adequate', cssSupport='poor', domImplementation='catastrophic';
I can't remember if I've ever done that inside a function body. It's a strange bug, and I've never seen it documented anywhere...