Javascript: Variable scope question

Joel Hammer Joel
Mon May 17 11:37:21 PDT 2004


I would appreciate it if anyone could comment on this.

I have written a long javascript, which, at the end of the day, only runs on
Opera and IE. (netscape, galeon, konqueror, mozilla  all fail to run
correctly.)

I am trying to track down why netscape 6.2 won't work.
One reason seems to be the typeof command. Netscape doesn't seem to support
it. This is a small annoyance.

But, a very big problem seems to be variable scope.

It is looking like IE and opera will allow a function to simply use a global
variable whereas Netscape insists that the variable, at least if it is an
array, be explicitly passed to it. This is fixable.

The third problem I don't know how to describe in few words. So, I'll give
the example:
<html>
<body>
<form name = "form1" action = "none">
   Big long form
</form>
<script>
form1[1].checked = true
</script>
</body>
</html>
Results in a form1 not defined error.
The odd thing is, netscape's later behavior indicates it knows about form1.

Opera and IE handle this situation just fine.

So, I am confused. 

Any insight appreciated.
Joel




More information about the Linux-users mailing list