471,122 Members | 1,168 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,122 software developers and data experts.

Yet another IE/W3C confusion

Don
I was recently handed responsibility for a web site that is a
combination of ASP, javascript, and some cgi-bin style programs which
generate HTML with javascript. Though I'm new to javascript, the
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
Zoloft.

One of the generated pages has this general structure:

<html>
<head>
<script type="text/javascript" src="/main.js"></script>
<script type="text/javascript" src="/file.js"></script>
<script type="text/javascript" language="JavaScript">
var url="http://www.yadayada.net";
var name="yada";
</script>
<title>Title</title>
</head>
<body onload="init();" >
<script type="text/javascript" src="/menu.js"></script>
....
</body>
</html>

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

The javascript in menu.js was slanted heavily toward IE 4, looks like it
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?

Jul 20 '05 #1
1 2573
Don wrote:
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. Has anyone else seen anything like this?


Only when somebody slipped HTML (<--//) in to the external JavaScript file.
A URL makes these things much easier to troubleshoot.

--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
Microsoft announces IE is dead (so upgrade):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Doug Farrell | last post: by
1 post views Thread by Mathias Mamsch | last post: by
38 posts views Thread by Grant Edwards | last post: by
10 posts views Thread by Kamilche | last post: by
reply views Thread by i_have_control | last post: by
13 posts views Thread by Steve | last post: by
10 posts views Thread by joelagnel | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.