[thelist] javaScript not Netscape Compliant

Simon Perry thelist at si-designs.co.uk
Thu Apr 15 14:43:56 CDT 2004


Casey Crookston wrote:

>I know, I know... Here comes Netcrap again.
>
>The script is to auto-force the same page to re-load when the user selects
>from a drop down menu...
>
><snip />
>
>Here is the online version:
>
>http://www.thecrookstons.com/roi/calc.asp
>
>What needs to change to make it work with Netscape?
>  
>
Casey,

Your chosen function name "goto" is a reserved identifier [0] plus your 
code is a little sloppy. The following should work nicely. I have 
corrected the script definition, renamed the function, added a semicolon 
at the end of the first var declaration and corrected dodument.location 
(sic). If IE was working with the original code then hats off to it but 
you can hardly blame Netscape ;-)

Simon

[0] http://dotnet.di.unipi.it/EcmaSpec/PartitionV/cont4.html or
http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf 
(p26 -14-)

<script type="text/javascript" language="JavaScript">
<!--
function swapTo(form) {
         var index=form.select.selectedIndex;
         if (form.select.options[index].value != "0") {
            document.location.href=form.select.options[index].value;
                                                      }
                    }
//-->
</script>

<form name="form1"><select name="select" onchange=
"swapTo(this.form)" size="1">


More information about the thelist mailing list