OnLoad focus problems with Netscape

Posted on 2000-02-23
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?



<%'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")

<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>

<body onload="document.login.loginid.focus();" BGCOLOR=#FFFFFF>
<span id="main" style="position:relative; z-index:1;">
 <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>
                 If invalidlogin="inactive" Then%>                                                                       <font face="Arial" size="4" color="Red">Account has been                             inactivated</font>                   
           <%End If
           End If%>
    Login ID <INPUT TYPE="TEXT" NAME="loginid">
    Password <INPUT TYPE="PASSWORD" NAME="password">
  If you are new user click <a HREF="newuser.asp">here.</a>
  Forgot your password??  <a HREF="emailpass.asp">click here.</a>
<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="">
Question by:ckosloski

Accepted Solution

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:


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


Author Comment

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



Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Capture logon name 13 70
How can I get this SlideToggle to behave? 6 23
execute script based on HTML event 7 22
how can i Return this word's max repeat count? 2 15
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

813 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

10 Experts available now in Live!

Get 1:1 Help Now