I have the following code layout
<script src="http://some.javascript/file.js"></script> // This should load first
<script language="JavaScript">
document.write('<SCR'+'IPT language="JavaScript1.1" SRC="http://a.link.to.an.external.url/that/returns/a/full/html/page/including/some/javascript">'); // This should load second
document.write('</SCR'+'IPT>');
</script>
MyJavascriptFunctionThatDependsOnStuffLoadedFromThe.documentWritePage(); <!-- Those files above should have loaded before this call -->
I know that it looks weird. Let's assume that it HAS to look like that for reasons that don't affect how the JS gets loaded. This does not need to work across browsers -- just WebKit browsers.
How do I make sure each of those documents loads completely before the next one? That is, how do I make sure that these documents load synchronously so that the function call at the end can assume appropriate state?
document.write()?document.write('</SCR'+'IPT>');