As an answer to the question of \'How do you automatically set the focus to a textbox when a web page loads?\', Espo suggests using
Using onLoad
is becoming less and less common because callbacks can't be stacked using this method, i.e. new onload
definitions override the old ones.
In modern frameworks like jQuery and its .load()
, callbacks can be stacked and there are no conflicts when using different scripts, plugins, etc. on the same page.
Also, it is widely regarded good practice to keep the markup separate from the code, so even if one would want to use onload
(which is perfectly okay if you control the complete environment and know what you're doing) one would attach that event on the scripting side either in the head
or a separate javaScript file:
window.onload = function() { document.getElementById...... }