Return to Snippet

Revision: 9490
at November 10, 2008 08:16 by kouphax


Initial Code
(function(){
	var forms = document.forms || [];
	for(var i = 0; i < forms.length; i++){
		for(var j = 0; j < forms[i].length; j++){
			if(forms[i][j].type != "hidden" && forms[i][j].disabled != true && forms[i][j].style.display != 'none'){
				forms[i][j].focus();
				return;
			}
		}
	}
})();

Initial URL

                                

Initial Description
This code, when placed at the end of the body tag will set focus on the first visible enabled element on the screen.  It considers visibility as well as all forms on-screen

Initial Title
Auto Focus First On-Screen Element

Initial Tags
javascript

Initial Language
JavaScript