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

Posted by Benny on Stack Overflow See other posts from Stack Overflow or by Benny
Published on 2009-09-17T20:10:45Z Indexed on 2010/05/31 0:12 UTC
Read the original article Hit count: 487

Hello,

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.

external.js

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

myPage.html

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

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)

Thanks, B.J.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about internet-explorer