M
monkeybug07
Im having a strange problem which I assume is an IE bug (since it
works in Mozilla).
I have a page that checks to see if a certain javascript file has been
referenced before calling any functions in it. If the file has not
been referenced, it adds the reference to the <head> element.
Here is the code:
<script type="text/javascript" language="JavaScript1.2">
if (window.myFunction == null) {
function dhtmlLoadScript(url)
{
var e = document.createElement("script");
e.src = url;
e.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(e);
}
dhtmlLoadScript("/javascript/adminFunctions.js");
if (window.myFunction == null) {
// IE will fall into here, Mozilla will not
alert("Javascript not loaded");
}
</script>
The strange part about this is that after the first message box
(whether it is an error or an alert) all calls to the functions in the
new javascript file work. It seems that a messagebox somehow
refreshes the DOM so that is sees the new element that has been
appended in the <head> element.
Has anyone had any experience with this? Or knows a work around?
Thanks.
works in Mozilla).
I have a page that checks to see if a certain javascript file has been
referenced before calling any functions in it. If the file has not
been referenced, it adds the reference to the <head> element.
Here is the code:
<script type="text/javascript" language="JavaScript1.2">
if (window.myFunction == null) {
function dhtmlLoadScript(url)
{
var e = document.createElement("script");
e.src = url;
e.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(e);
}
dhtmlLoadScript("/javascript/adminFunctions.js");
if (window.myFunction == null) {
// IE will fall into here, Mozilla will not
alert("Javascript not loaded");
}
</script>
The strange part about this is that after the first message box
(whether it is an error or an alert) all calls to the functions in the
new javascript file work. It seems that a messagebox somehow
refreshes the DOM so that is sees the new element that has been
appended in the <head> element.
Has anyone had any experience with this? Or knows a work around?
Thanks.