0
votes

this is my code beetwen script tag :

        function open()
        {
            file = "Test1.js";
            document.write("<script type='text/javascript' src='"+file+"'></scr"+"ipt>");
            document.getElementById("id").innerHTML = doc;
        }
content of Test1.js is "var doc = hello wolrd' ".But why it doesn't showed..
any one can help me??
1

1 Answers

4
votes

doc won't be assigned until Test1.js is executed, and that won't be executed until your current script has finished executing.

If you want something to happen after Test1.js has loaded an executed, you'll need to check for its load event.