I was recently handed responsibility for a web site that is a
language isn't causing my any headaches but the difference in how code
gets processed by different browsers is enough to send me searching for
One of the generated pages has this general structure:
<body onload="init();" >
main.js contains general purpose functions used within the body
init() is in file.js and sets up for code in menu.js
menu.js references functions in file.js
supports NS 4, and doesn't function properly in NS6/Mozilla. So I
reworked it to work with the W3C DOM. Running from files on my local
drive, the pages and menus displayed correctly in both IE6 and Mozilla
1.3 so I pushed them over to the test server. Loaded from there the
code works correctly in Mozilla but in IE6 it throws an error because it
can't find the init() function which is in file.js Taking init() out of
the body tag makes no difference to Mozilla which continues to display
the menu correctly. But without the init() IE shows nothing.
However, if instead of using a <script ... src=file.js> tag, I take the
code from file.js and but it in-line within a script block, IE can find
the init() function and display everything correctly.
It looks as if IE is holding of on reading the script files until after
the body has loaded. Since it hasn't read the file with the init()
function in it, it can't find it.
Has anyone else seen anything like this?