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...... }
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…