Picky window.onload in IE or am I going insane?

A

Alaric

O.k... I've divided my source code into a few different files for
organizational purposes using the aptly named function Include I got
online. I think the rest of the code is irrelevant, but if I'm wrong,
just request it. Here's the HTML.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>NorthWood HighSchool Environmental Awareness Society</title>
<script type="text/javascript" src="javascript/tools.js"></script>
</head>

<body>
<div style="width:800px; border:#CCC thick inset; background-
color:Black; color:#FFFFFF;" class="ticker">
Please enable javascript to view this news ticker.
</div>
<div class="ticker">
There is no new news from iraq.
</div>
</body>
</html>

And here's the master javascript file that include()'s the rest of
them.

// JavaScript Document

function include(filename)
{
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.src = filename;
script.type = 'text/javascript';
head.appendChild(script);
}

include("/javascript/classes.js");
include("/javascript/fade.js");
include("/javascript/ticker.js");

alert("Hello World");

This code works just fine. However when I comment out the last line,
(//alert("Hello World");), the window.onload that I set in javascript/
classes.js fails to load. I've tested it on two different computers
with the ie7 browser, and both fail. Mozilla reads it just fine...
Which can lead to only one of two roads. Either Microsoft is insane,
or I am. Can anyone spot the bug?
 
D

David Mark

O.k... I've divided my source code into a few different files for
organizational purposes using the aptly named function Include I got
online.  I think the rest of the code is irrelevant, but if I'm wrong,

Why would you use a function to include script?
just request it.  Here's the HTML.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www..w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

That is the most useless of all the doctypes, particularly for IE.
Use HTML strict.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>NorthWood HighSchool Environmental Awareness Society</title>

Ah, the good ol' NWHSEAS. BTW, "high school" is two words.
<script type="text/javascript" src="javascript/tools.js"></script>

It will be hard to debug this without seeing this script.
</head>

<body>
<div style="width:800px; border:#CCC thick inset; background-
color:Black; color:#FFFFFF;" class="ticker">
Please enable javascript to view this news ticker.
</div>

What if they can't?
<div class="ticker">
There is no new news from iraq.

No news is good news. Also, Iraq is the name of a country.
</div>
</body>
</html>

And here's the master javascript file that include()'s the rest of
them.

What is a "master javascript file?" Is it the previously mentioned
tools.js?
// JavaScript Document

function include(filename)
{
        var head = document.getElementsByTagName('head')[0];
        var script = document.createElement('script');
        script.src = filename;
        script.type = 'text/javascript';
        head.appendChild(script);

}

Throw that away and use a script tag.
include("/javascript/classes.js");
include("/javascript/fade.js");
include("/javascript/ticker.js");

alert("Hello World");

This code works just fine. However when I comment out the last line,
(//alert("Hello World");), the window.onload that I set in javascript/
classes.js fails to load.  I've tested it on two different computers

It is unfortunate that you set it in code that wasn't included in this
post.
with the ie7 browser, and both fail.  Mozilla reads it just fine...
Which can lead to only one of two roads.  Either Microsoft is insane,

Microsoft's developers are insane, but that doesn't exclude the
possibility that you are too. It is hard to say without seeing the
script in question.
or I am.   Can anyone spot the bug?

Sorry, can't spot it from here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top