Javascript – Is the load order for external javascript files different in IE8 compared to IE7


I ask because I'm running an application in which I load an external script file in the HEAD section of the page, and then attempt to call a function from it in the onLoad section of the BODY tag.


function someFunction()
   alert("Some message");


    <script type="text/javascript" language="javascript" src="external.js"></script>
  <body onLoad="someFunction();">

Using the developer tools in IE8, I get an exception thrown at the onLoad statement because, apparently, the external javascript file hasn't been loaded yet.

I haven't had this problem come up in IE7 before, thus my question.

Did they change the load order between IE7 and IE8? If so, is there a better way to do this? (the real function references many other functions and constants, which look much better in an external file)


Best Solution

Well, I feel pretty stupid actually.

Turns out the problem wasn't with the load order. The problem was that the external javascript file had a syntax error in one of its functions, and apparently when the exception was thrown it completely invalidated the whole file, thus making the rest of the functions unavailable to the main page.

I'm not sure if this behavior is different in IE8 compared to IE7, but anyway, that was the real problem.

Thanks for your reply.