|
March 1, 2001 Indirect External File Loading Tips: March 2001
Yehuda Shiran, Ph.D.
|
|
Internet Explorer 5.5 and Netscape
6 differ from previous versions in the way they dynamically load external scripts.
Here, the term "dynamic loading" refers to the case where you document.write
the include statement on the fly. Suppose you have the following external script:
and you want to dynamically load it from the main html code:
Now, suppose you want to call the
Try it. You get an error message. The reason for this failure is that both Internet Explorer 5.5 and Netscape 6 do not wait for the external script to be read before continuing parsing the main script.
One of the remedies for this problem is to use indirection. Put a static include in your main program, and then write the dynamic loading command (
In the file
Your main page should like like this now:
Check it out. You should get the alert message "Hello From External."
People who read this tip also read these tips: Look for similar tips by subject: |