Some suggestions:
Use more whitespaces and semicolons
Initialise Arrays with
[]
var snowcolor = ["#aaaacc", "#ddddFF", "#ccccDD"];
Use naming conventions for variables and method names to make them more readable
initSnow() or init_snow() browserInfos or browser_infos
In JavaScript it is recommended to combine several variable declerations. So instead of
var marginbottom var marginright var timer
you can write
var marginbottom, marginright, timer;
Instead of passing a string to
setTimeout
, you can pass a reference to the function directlyvar timer = setTimeout(movesnow, 50);
There are some magic numbers in your code, that you might want to extract into variables.
Since JavaScript doesn't have
final static
variables (afaik), consider marking them via naming conventions. For example:var SNOW_MAX_SIZE = 22;
The four if statements inside
initsnow
andmovesnow
seem to be the same, so you could move them to a seperate function. However, you currently havesnowingzone
set to a fixed value and you don't change it. So as it is, the if statements are unnecessary.Some variable names are rather cryptic:
x_mv
,lftrght
, etc.There are unused variables: e.g.
i_snow
The browser identification and the "calculation" of
browserok
seem to be good candidates for a seperate function.
Update Added 8. - 11.
If you are feeling confident or want to try static code analysis, you might want to look into something like http://www.jslint.com/ or http://www.jshint.com/ . They can warn you about global variables, unused variables and more.
ad 4) As Schism mentioned, this advices may lead to unwanted global variables if you mix up ,
and ;
. So for example:
function foo() {
var a,
b; // Oops! ; should be ,
c; // c is now a global variable
}