asdf

  • Thread starter Christopher Benson-Manica
  • Start date
C

Christopher Benson-Manica

I'm trying to create script that can dynamically execute script from a
given source and then call a callback function when complete. I have
the following...

function bar() {
alert( 'bar' );
}
function foo() {
var s=document.getElementById( 'dynamicScriptElement' );
if( !s ) {
s=document.createElement( 'script' );
s.type='text/javascript';
s.id='dynamicScriptElement';
document.documentElement.childNodes[1].appendChild( s );
}
s.src='test.js';
bar();
}

1) Is the script in test.js guaranteed to be executed before bar() is
called?
2) foo() assumes that the <html> element has a <head> and <body> -
presumably that's reasonable, right?
3) Any other comments would be appreciated!
 
C

Christopher Benson-Manica

Christopher Benson-Manica said:
I'm trying to create script that can dynamically execute script from a
given source and then call a callback function when complete. I have
the following...

I screwed up the subject of this post and so I have reposted with a more
appropriate subject. Sorry.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,733
Latest member
LonaMonzon

Latest Threads

Top