Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Help: appendChild and IE bug

Reply
Thread Tools

Help: appendChild and IE bug

 
 
monkeybug07
Guest
Posts: n/a
 
      09-02-2003
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.




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xhtml, innerHtml, appendChild, and innerHTML. what is the exact proper way to do this with DOM sonic Javascript 5 07-11-2006 08:17 AM
if you have used createElement() and appendChild() on a page, how do you capture all the HTML to write to PHP? Jake Barnes Javascript 15 02-07-2006 06:31 AM
removeChild and appendChild for Span JehanNYNJ@aol.com Javascript 1 05-03-2005 07:22 PM
calculating in table made by createElement and appendChild kie Javascript 25 10-07-2003 11:38 AM
img object and appendChild problem Bob Javascript 0 08-22-2003 06:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57