var foo; if ( document.getElementById ) { foo = document.getElementById('foo'); } elsif ( document.all ) { foo = document.all['foo']; } ...