[thelist] Direct focus on login

brian cummiskey brian at hondaswap.com
Mon Nov 22 09:38:52 CST 2004


Andreas Wahlin wrote:

> I want to place the cursor on the userid area of a loginscreen, so
> user's won't have to click on it. Should be easy javascript:
> 
> <body onload="document.getElementById("userid").focus();">
> <input type="text" id="userid" name="userid" />
> </body>
> 
> However, the cursor won't start to blink/being active unltil I click
> once on the actual page, (though that click can be anywhere). This
> defeats the entire purpouse. It's like, sure the input is focused, but
> the window isn't focused, but it is. I have tried refreshing the window
> and I've tried opening a fresh window and paste the url and then go
> there, and nothing makes it so I can start typing directly without first
> clicking somewhere on the window.
> (hope this hasn't been asked before, I did some googling)
> 
> Andreas

Try using somethign like this.  Less advanced, but it works:

<head>
<script type="text/javascript">
function setfocus(){
	document.formname.userid.focus();
}
</script>
</head>

<body onload="setfocus();">
<form name="formname">
<input type="text" id="userid" name="userid" />
</form>
</body>




More information about the thelist mailing list