[Javascript] my code not working in netscape,but working on ie

Rodney Myers rodney at aflyingstart.net
Fri Jun 8 04:50:17 CDT 2001


Suresh,

I found a few things:

1) At end of the main script you have

-->
</SCRIPT>

It should be

//-->
</SCRIPT>


2) Your script at the end of the file duplicates the onload function but
does not properly define the form

<script language="javascript">
<!--
loginform.loginid.focus();
//-->
</script>

This script is not required, because you have
<body ... onload="document.loginform.loginid.focus()">
but if it were it would need
document.loginform.loginid.focus();

3) IMG onclick events d not happen in Netscape 4. (NN6 anyone?)
<img name= submit1
src="images/submit.jpg" width=81 height=46 onClick="return func1()">

There is a simple way of having a graphic submit which would be

<input type="image" src="images/submit.jpg" width=81 height=46>
Note that the onClick="return func1()" is not need as the form will be
submitted when you click and you have
   <form name=loginform method=post
action="logincheck.asp" onSubmit="return func1()" >

4) The onsubmit function could be improved by
a) passing it the form object
   <form ... onSubmit="return(func1(this));" >
b) returning a true/false value rather than using the function to submit
the form
    having only one return() IMHO aids clarity.

This allows the function to be rewritten like this:
A function which on a second look did not seem to properly define the
form object since document was omitted.

function func1(form)   {
var ret=true;
        if (trim(form.loginid.value)=="")
        {
                alert("Login ID is not entered");
                form.loginid.value="";
                form.loginid.focus();
                ret=false;
        }
        if (form.passwrd.value=="")
        {
                alert("Password is not entered");
                form.passwrd.focus();
                ret=false;
        }
return(ret);
}

--
Note that user entered values in
  <input type="password"
  cannot be read by scripts in Javascript 1.0 and 1.1 (old browsers)
  1.2 can certainly read them, but cannot write values which will affect
what gets submitted.
  (O'Reilly:Flanagan:3Ed:p645)
  This general point does not affect your particular script.

hth

Rodney


suresh s wrote:

> please help!!
>
> my code is not working on netscape but working fine on
> ie.
> my code follows:

--
Shop at ssistant Add-ons and Developer Workshops
http://www.aflyingstart.net/addons/

Enquiries regarding Shop at ssistant Classic training :
Call 01256 880770

Rodney Myers
Based in Oxford, England
Technical Director, Shop at ssistant eCommerce Solutions






More information about the Javascript mailing list