Is this Java script?

G

GS

we are using the following script for cursor to goto default position,
is this script is java script or not?. can somebody tell me. I got this
script from Internet, our client told us not to use any Java script to
set the cursor to default position. Thanks in advance.

onload="document.login.userrname.focus();"
 
E

Evertjan.

GS wrote on 26 okt 2006 in comp.lang.javascript:
we are using the following script for cursor to goto default position,
is this script is java script or not?.

It is not Java Script, because Java has no script.

It is ..... Javascript.
That is the part between the "" is.

Without the ; it could also be vbscript in IE,
since in fact it is mainly DOM.
can somebody tell me. I got this
script from Internet, our client told us not to use any Java script to
set the cursor to default position. Thanks in advance.

Ignore him and do what you think best!

Chances are he will not pay, however, for being ignored. ;-}

onload="document.login.userrname.focus();"

More cross browser safe use:

<body
onload="document.forms['login'].elements['userrname'].focus();">
 
P

Peter Michaux

GS said:
we are using the following script for cursor to goto default position,
is this script is java script or not?. can somebody tell me. I got this
script from Internet, our client told us not to use any Java script to
set the cursor to default position.

If the client wants the curosr set to the default position then isn't
JavaScript the only way to do this?

Regardless don't do this unless you will take special care. I'm usually
half way through typing my password by the time the page loads. Then
the focus is changed and the last half of my password is typed in the
username field. So unless you are going to write code that looks for
what has already been typed and takes care of this situation don't
bother with the JavaScript to set focus.

Peter
 
M

Matt Kruse

Evertjan. said:
<body
onload="document.forms['login'].elements['userrname'].focus();">

Or if you want to be hard-core and robust... ;)

<script type="text/javascript">
window.onload = function() {
var f,lf,u,t;
if ((f=document.forms)
&& (lf=f.login)
&& (u=lf.elements.username)
&& (t=u.type)
&& ("text"==t)
&& (u.value==u.defaultValue)
) {
u.focus();
}
}
</script>
 
R

Randy Webb

Peter Michaux said the following on 10/25/2006 6:53 PM:
If the client wants the curosr set to the default position then isn't
JavaScript the only way to do this?

No.
 
E

Evertjan.

Matt Kruse wrote on 26 okt 2006 in comp.lang.javascript:
Evertjan. said:
<body
onload="document.forms['login'].elements['userrname'].focus();">

Or if you want to be hard-core and robust... ;)

<script type="text/javascript">
window.onload = function() {
var f,lf,u,t;
if ((f=document.forms)
&& (lf=f.login)
&& (u=lf.elements.username)
&& (t=u.type)
&& ("text"==t)
&& (u.value==u.defaultValue)
) {
u.focus();
}
}
</script>

Wow, U.topValue, U in element, U in form now(), Mat.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,211
Latest member
NelleWilde

Latest Threads

Top