Revision: 17198
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 26, 2009 17:58 by neoprolog
Initial Code
var focusFirstInput = function(obj) { var forms = (obj && document.getElementById(obj)) ? document.getElementById(obj).getElementsByTagName('form') : document.forms; if (forms.length > 0 && document.forms[0].elements[0]){ var eltype = document.forms[0].elements[0].type; (eltype=="text" || eltype=="textarea" || eltype=="select-one" || eltype=="select-multiple" || eltype=="password") ? forms[0].elements[0].focus() : null; } }
Initial URL
Initial Description
Usage: //any element window.onload = function(){ focusFirstInput(); } or // form elements under 'content-body' window.onload = function(){ focusFirstInput('content-body'); }
Initial Title
Focus first 'focus'able form field on load (DOM)
Initial Tags
form, javascript, forms, DOM
Initial Language
JavaScript