/ Published in: JavaScript
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
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(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; } } } })();