The body of my HTML is as follows:
<body onload="DoLoad();">
</body>
When I define the DoLoad function in the SCRIPT tag at the top of the HTML file, it works fine. For example:
<head>
<title></title>
<script type="text/javascript">
function DoLoad() {
alert("Hello");
}
</script>
</head>
However, when I put the function in a file called "TestJS.js" and reference it using the SRC attribute of the SCRIPT tag, then it doesn't run. In that scenario, the HTML head would look like this:
<head>
<title></title>
<script type="text/javascript" src="TestJS.js" />
</head>
And the "TestJS.js" file would look like this:
function DoLoad() {
alert("Hello");
}
Any idea of why the function would work with the inline JavaScript but not with the imported JavaScript? I would rather have my code defined in an external file, so getting it to work that way would be ideal.
FYI, I am using Visual Studio 2008 Professional and I am working with an ASP.NET Web Application. My operating system is Windows Vista Home Premium. My browser is Internet Explorer 8.