Rate this script:  I Love it  /   I Hate it

give focus to first input field or textarea on page


Code


Event.observe(window, 'load', function() {
  var e = $A(document.getElementsByTagName('*')).find(function(e) {
    return (e.tagName.toUpperCase() == 'INPUT' && (e.type == 'text' || e.type == 'password'))
        || e.tagName.toUpperCase() == 'TEXTAREA' || e.tagName.toUpperCase() == 'SELECT';
  });
  if (e) e.focus();
});
 

 

 
give focus to first input field or textarea on page scripts | give focus to first input field or textarea on page snippet | give focus to first input field or textarea on page example | give focus to first input field or textarea on page tutorial | give focus to first input field or textarea on page code