Dynamic load of js script failure in IE 6

R

rh

Executing the script given below Opera, Netscape and Mozilla
successfully load the js file in both the "main" and "test" window.
However, while IE 6 manages to load OK in "main", it produces the
"Load failed in test" alert.

IE behaviour is the same if a local file is used for the js source, so
the problem doesn't appear to be zone security related.

Any ideas of what's wrong here, or what needs to be done to get it to
work in IE?

Thanks,

../rh

<html>
<head>
<script type="text/javascript"
src="http://www3.telus.net/rhall/testLoad.js"></script>
<script>
self.name = "main";
if (typeof myFunc != "undefined") alert("Loaded OK in "+self.name);
else alert("Load failed in "+self.name);

var win = window.open("","test");
win.document.open();
win.document.write(
'<html>\n'
+ '<body>\n'
+ '<script type="text/javascript"
src="http://www3.telus.net/rhall/testLoad.js"> <\/script>\n'
+ '<script>\n'
+ ' if (typeof myFunc != "undefined") alert("Loaded OK in
"+self.name);\n'
+ ' else alert("Load failed in "+self.name);\n'
+ '<\/script>\n'
+ '</body>\n'
+ '</html>\n'
);
win.document.close();
</script>
</head>
<body>
</body>
</html>
 
R

rh

Any ideas of what's wrong here, or what needs to be done to get it to
work in IE?

It turns out on further testing, the load of the js file actually
occurs in the "test" window in IE 6. But the loading is being done
asynchronously, and is not completed at the time the test for the
function presence is carried out. That's not supposed to happen
(unless there's a defer), right?
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top