index.html\[code\]<html><head><script type="text/javascript" src="http://stackoverflow.com/questions/15751362/foo.js"></script><script type="text/javascript">window.onload = function() { console.log("hello from html");};</script></head><body><div class="bar">bar</div></body></html>\[/code\]foo.js\[code\]// this js file will be completely ignored with window.onload//window.onload = function() { console.log("hello from external js"); var bar = document.getElementsByClassName("bar"); // this returns 0 instead of 1 console.log(bar.length);//};\[/code\][*]When \[code\]window.onload\[/code\] is used in html, \[code\]window.onload\[/code\] from external js will be ignored.[*]When \[code\]window.onload\[/code\] from external js is commented out, \[code\]bar.length\[/code\] returns 0.[*]When \[code\]window.onload\[/code\] from html is removed, \[code\]window.onload\[/code\] from external js works fine.Can anyone explain why I can't use both \[code\]window.onload\[/code\]?If I had to use \[code\]window.onload\[/code\] in html, how do tell if window is loaded from external js?