Solved

OnLoad focus problems with Netscape

Posted on 2000-02-23
2
293 Views
Last Modified: 2008-03-06
I want to loginid text box to get the focus when the form loads.  The following code works great in IE but does not work in Netscape.
I get the Javascript error, "document.login has no properties".  

Can you tell me what I'm doing wrong?

Thanks

Corey

<%@ LANGUAGE="VBSCRIPT" %>
<%'Set employee cookie to nothing.
Response.Buffer = True
Response.Cookies("markCustomer").Expires = Date() - 1
      
'Retrieve login validation data if there is any.
invalidlogin = Request.Querystring("login")
%>

<html>
<head>
<meta HTTP-EQQUIV="Content-Type" CONTENT="text/html;charset=windows-1252">
<title>Login to Intelimind Customer Support</title>
<SCRIPT LANGUAGE="JavaScript"><!--//cloak
if (top.location.href != location.href)
      top.location.href = location.href;
//uncloak --></SCRIPT>
</head>

<body onload="document.login.loginid.focus();" BGCOLOR=#FFFFFF>
<span id="main" style="position:relative; z-index:1;">
<CENTER>
 <h1 align="center"><font face="AvantGarde Md BT" size="7"        color="#B22222">Intelimind</font></h1>
 <FORM NAME="login" ACTION="validation.asp" METHOD="GET"        Target=_top>
   <H2>Login to customer support</H2><P>
   <% 'Determine if the loginid/password is invalid.
          If invalidlogin="true" Then%>      
             <font face="Arial" size="4" color="Red">Invalid loginid or                      password</font>
        <%Else
                 If invalidlogin="inactive" Then%>                                                                       <font face="Arial" size="4" color="Red">Account has been                             inactivated</font>                   
           <%End If
           End If%>
                  
   <PRE>
    Login ID <INPUT TYPE="TEXT" NAME="loginid">
    Password <INPUT TYPE="PASSWORD" NAME="password">
   </PRE>
   <INPUT TYPE=SUBMIT  VALUE="Login">
   <INPUT TYPE=RESET   VALUE="Reset">
  </FORM>
  If you are new user click <a HREF="newuser.asp">here.</a>
  <br>
  <br>
  Forgot your password??  <a HREF="emailpass.asp">click here.</a>
 </CENTER>
 </span>
<span id="theWatermark" style="position:absolute; z-index:0; top:0; left:340">
<img  src="images/swirl.gif" width=400 height=400 border=0 alt="">
</span>
</body>
</html>
0
Comment
Question by:ckosloski
2 Comments
 

Accepted Solution

by:
npappas earned 50 total points
ID: 2550558
onLoad is evil -- it never does *exactly* what you expect.

Remove onLoad and put the code block at the bottom:

....
<BODY BGCOLOR=#FFFFFF>
.....
.....
<SCRIPT LANGUAGE="JavaScript">
document.login.loginid.focus();
</SCRIPT>
</BODY>
</HTML>

This will do what onLoad should do, and it doesn't cause any problems.

Nick
0
 
LVL 4

Author Comment

by:ckosloski
ID: 2550602
I moved the script code after the end of the form (</form>) and it worked great!!

Thanks

Corey
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now