Gossamer Forum
Quote Reply
Cursor start position
Is it possible to have the cursor positioned inside the search box when page loads?

Z
Quote Reply
Re: [Z] Cursor start position In reply to
Sure. Just put this between the <head> ... </head>

Code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements.type == "text") || (field.elements.type == "textarea") || (field.elements.type.toString().charAt(0) == "s")) {
document.forms[0].elements.focus();
break;
}
}
}
}
// End -->
</script>

Then this:

Code:
<body onload="placeFocus()">

--------------------------------
Privacy Software